Skip to content

Commit 4466d6d

Browse files
HiassofTgregkh
authored andcommitted
tty: fix crash in release_tty if tty->port is not set
Commit 2ae0b31 ("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: 2ae0b31 ("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>
1 parent 0c5fc92 commit 4466d6d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/tty/tty_io.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,10 +1515,12 @@ static void release_tty(struct tty_struct *tty, int idx)
15151515
tty->ops->shutdown(tty);
15161516
tty_save_termios(tty);
15171517
tty_driver_remove_tty(tty->driver, tty);
1518-
tty->port->itty = NULL;
1518+
if (tty->port)
1519+
tty->port->itty = NULL;
15191520
if (tty->link)
15201521
tty->link->port->itty = NULL;
1521-
tty_buffer_cancel_work(tty->port);
1522+
if (tty->port)
1523+
tty_buffer_cancel_work(tty->port);
15221524
if (tty->link)
15231525
tty_buffer_cancel_work(tty->link->port);
15241526

0 commit comments

Comments
 (0)