Commit 55d7b689 authored by Tetsuo Handa's avatar Tetsuo Handa Committed by Linus Torvalds

serial: access after NULL check in uart_flush_buffer()

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: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: <stable@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3f9827bc
...@@ -556,7 +556,7 @@ static int uart_chars_in_buffer(struct tty_struct *tty) ...@@ -556,7 +556,7 @@ static int uart_chars_in_buffer(struct tty_struct *tty)
static void uart_flush_buffer(struct tty_struct *tty) static void uart_flush_buffer(struct tty_struct *tty)
{ {
struct uart_state *state = tty->driver_data; struct uart_state *state = tty->driver_data;
struct uart_port *port = state->port; struct uart_port *port;
unsigned long flags; unsigned long flags;
/* /*
...@@ -568,6 +568,7 @@ static void uart_flush_buffer(struct tty_struct *tty) ...@@ -568,6 +568,7 @@ static void uart_flush_buffer(struct tty_struct *tty)
return; return;
} }
port = state->port;
pr_debug("uart_flush_buffer(%d) called\n", tty->index); pr_debug("uart_flush_buffer(%d) called\n", tty->index);
spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment