staging: sb105x: fix potential NULL pointer dereference in mp_chars_in_buffer()

The dereference to 'state' should be moved below the NULL test.

Cc: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Wei Yongjun 2012-11-28 21:30:01 -05:00 committed by Greg Kroah-Hartman
parent 218cbbd821
commit b0ab023611
1 changed files with 2 additions and 1 deletions

View File

@ -689,13 +689,14 @@ static int mp_chars_in_buffer(struct tty_struct *tty)
static void mp_flush_buffer(struct tty_struct *tty) static void mp_flush_buffer(struct tty_struct *tty)
{ {
struct sb_uart_state *state = tty->driver_data; struct sb_uart_state *state = tty->driver_data;
struct sb_uart_port *port = state->port; struct sb_uart_port *port;
unsigned long flags; unsigned long flags;
if (!state || !state->info) { if (!state || !state->info) {
return; return;
} }
port = state->port;
spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->lock, flags);
uart_circ_clear(&state->info->xmit); uart_circ_clear(&state->info->xmit);
spin_unlock_irqrestore(&port->lock, flags); spin_unlock_irqrestore(&port->lock, flags);