Skip to content

Commit

Permalink
serial: core: fix potential NULL pointer dereference
Browse files Browse the repository at this point in the history
The commit 761ed4a ("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: 761ed4a ("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>
  • Loading branch information
Andy Shevchenko authored and Greg Kroah-Hartman committed Sep 15, 2016
1 parent 0ae9fde commit a5a2b13
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/tty/serial/serial_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a5a2b13

Please sign in to comment.