From b8f1ab847c744e09817831f84d3b323ccccc7167 Mon Sep 17 00:00:00 2001 From: Lei wang Date: Fri, 8 Sep 2017 10:34:18 +0800 Subject: [PATCH] tty: serial_core: add tty NULL check to uart_tx_stopped Commit 761ed4a94582 ("tty: serial_core: convert uart_close to use tty_port_close") created a case where a port used for a console does not get shutdown on tty closing. Then a call to uart_tx_stopped() segfaults because the tty is NULL. This could be fixed to restore old behavior, but we also want to allow tty_ports to work without a tty attached. So this change to allow a NULL tty_struct is needed either way. Fixes: 761ed4a94582 ("tty: serial_core: convert uart_close to use tty_port_close") Reported-by: kernel test robot Signed-off-by: Rob Herring Signed-off-by: Greg Kroah-Hartman Change-Id: Ifbeeacc89d396b857332ce94cc2d77bdd6e12bb7 Git-repo: git://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git Git-commit: a727b025f43d7952c0697562f5cecda9f42758aa Signed-off-by: Lei wang --- include/linux/serial_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index b2c1ea2a4739..f276869a945e 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -402,7 +402,7 @@ int uart_resume_port(struct uart_driver *reg, struct uart_port *port); static inline int uart_tx_stopped(struct uart_port *port) { struct tty_struct *tty = port->state->port.tty; - if (tty->stopped || port->hw_stopped) + if ((tty && tty->stopped) || port->hw_stopped) return 1; return 0; }