diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2016-09-13 00:23:42 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-09-15 12:35:49 +0200 |
commit | a5a2b13074fd8d290bad32a5b0a0c5be9f3a84fa (patch) | |
tree | 46bc2c52942c37363e17dc750884e0954642ae10 /drivers/tty/serial/serial_core.c | |
parent | 0ae9fdefb6c37237d826d6195e27810ffcc0b6e0 (diff) |
serial: core: fix potential NULL pointer dereference
The commit 761ed4a94582 ("tty: serial_core: convert uart_close to use
tty_port_close") refactored uart_close() to use tty_port_close(). At the same
time it introduced a potential NULL pointer dereference. Rearrange the code to
avoid kernel crash.
Fixes: 761ed4a94582 ("tty: serial_core: convert uart_close to use tty_port_close")
Cc: Rob Herring <robh@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/serial_core.c')
-rw-r--r-- | drivers/tty/serial/serial_core.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 6b7f857fc3b0..6e4f63627479 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1484,15 +1484,15 @@ static void uart_tty_port_shutdown(struct tty_port *port) struct uart_state *state = container_of(port, struct uart_state, port); struct uart_port *uport = uart_port_check(state); - spin_lock_irq(&uport->lock); /* * At this point, we stop accepting input. To do this, we * disable the receive line status interrupts. */ - WARN(!uport, "detached port still initialized!\n"); + if (WARN(!uport, "detached port still initialized!\n")) + return; + spin_lock_irq(&uport->lock); uport->ops->stop_rx(uport); - spin_unlock_irq(&uport->lock); uart_port_shutdown(port); |