tty: fix crash in release_tty if tty->port is not set
authorMatthias Reichl <hias@horus.com>
Thu, 5 Nov 2020 12:34:32 +0000 (13:34 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Nov 2020 11:39:07 +0000 (12:39 +0100)
commitdb495aa9fb84c083333d48ab8e560274f504f0fc
tree0a092215a15fa0c0a18a3a0b3eec75b4af6dc374
parentd3f90dcc09090bf6f0f034be750c3e0ddfa35a29
tty: fix crash in release_tty if tty->port is not set

commit 4466d6d2f80c1193e0845d110277c56da77a6418 upstream.

Commit 2ae0b31e0face ("tty: don't crash in tty_init_dev when missing
tty_port") didn't fully prevent the crash as the cleanup path in
tty_init_dev() calls release_tty() which dereferences tty->port
without checking it for non-null.

Add tty->port checks to release_tty to avoid the kernel crash.

Fixes: 2ae0b31e0face ("tty: don't crash in tty_init_dev when missing tty_port")
Signed-off-by: Matthias Reichl <hias@horus.com>
Link: https://lore.kernel.org/r/20201105123432.4448-1-hias@horus.com
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/tty_io.c