From: Tetsuo Handa Date: Thu, 8 May 2008 21:06:17 +0000 (+0000) Subject: serial: access after NULL check in uart_flush_buffer() X-Git-Tag: v2.6.25.4~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a57a7ee4005e63d1239b349aa8167093d93a11f;p=thirdparty%2Fkernel%2Fstable.git serial: access after NULL check in uart_flush_buffer() commit 55d7b68996a5064f011d681bca412b6281d2f711 upstream I noticed that static void uart_flush_buffer(struct tty_struct *tty) { struct uart_state *state = tty->driver_data; struct uart_port *port = state->port; unsigned long flags; /* * This means you called this function _after_ the port was * closed. No cookie for you. */ if (!state || !state->info) { WARN_ON(1); return; } is too late for checking state != NULL. Signed-off-by: Tetsuo Handa Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index 0f5a17987ccac..3bf9294a2c35e 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c @@ -535,7 +535,7 @@ static int uart_chars_in_buffer(struct tty_struct *tty) static void uart_flush_buffer(struct tty_struct *tty) { struct uart_state *state = tty->driver_data; - struct uart_port *port = state->port; + struct uart_port *port; unsigned long flags; /* @@ -547,6 +547,7 @@ static void uart_flush_buffer(struct tty_struct *tty) return; } + port = state->port; pr_debug("uart_flush_buffer(%d) called\n", tty->index); spin_lock_irqsave(&port->lock, flags);