From: Wei Yongjun Date: Thu, 29 Nov 2012 02:30:01 +0000 (-0500) Subject: staging: sb105x: fix potential NULL pointer dereference in mp_chars_in_buffer() X-Git-Url: http://git.mmlx.us/?a=commitdiff_plain;h=b0ab02361167faa82198b783a8d555eb6f58901c;p=linux-edison.git 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 Signed-off-by: Wei Yongjun Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/sb105x/sb_pci_mp.c b/drivers/staging/sb105x/sb_pci_mp.c index fbebf88226d..edb2a85b9d5 100644 --- a/drivers/staging/sb105x/sb_pci_mp.c +++ b/drivers/staging/sb105x/sb_pci_mp.c @@ -689,13 +689,14 @@ static int mp_chars_in_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_port *port = state->port; + struct sb_uart_port *port; unsigned long flags; if (!state || !state->info) { return; } + port = state->port; spin_lock_irqsave(&port->lock, flags); uart_circ_clear(&state->info->xmit); spin_unlock_irqrestore(&port->lock, flags);