Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 1481ecf1 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Greg Kroah-Hartman
Browse files

serial: sh-sci: Fix use-after-free on subsequent port startup



sci_request_irq() checks port->irqstr[j] for a NULL pointer, to decide
if a fallback interrupt name string should be allocated or not.

While this string is freed during port shutdown, the pointer is not
zeroed.  Hence on a subsequent startup of the port, it will still be
pointing to the freed memory, leading to e.g.

    WARNING: CPU: 0 PID: 404 at fs/proc/generic.c:388 __proc_create+0xbc/0x260
    name len 0

or to a crash (the latter is more likely with CONFIG_DEBUG_SLAB=y, due
to the poisoning of freed memory).

Instead of zeroeing the pointer at multiple places, preinitialize
port->irqstr[j] to zero to fix this.

Fixes: 8b0bbd95 ("serial: sh-sci: Add support for R7S9210")
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarUlrich Hecht <ulrich.hecht+renesas@gmail.com>
Reviewed-by: default avatarSimon Horman <horms+renesas@verge.net.au>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fefe287e
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment