]> git.neil.brown.name Git - history.git/commitdiff
[SERIAL] Fix missing NULL check
authorRussell King <rmk@flint.arm.linux.org.uk>
Sat, 24 Jan 2004 21:23:50 +0000 (21:23 +0000)
committerRussell King <rmk@flint.arm.linux.org.uk>
Sat, 24 Jan 2004 21:23:50 +0000 (21:23 +0000)
tty->driver_data or state->port may end up being NULL in uart_close.
Make sure that we correctly clean up in this case, rather than
oopsing.

drivers/serial/serial_core.c

index c0fbca8849b7776c4804315212936b2605d97a71..3f403b5e5816b6f6b5bd69635c18018ec2c8889a 100644 (file)
@@ -1208,9 +1208,15 @@ static void uart_set_termios(struct tty_struct *tty, struct termios *old_termios
 static void uart_close(struct tty_struct *tty, struct file *filp)
 {
        struct uart_state *state = tty->driver_data;
-       struct uart_port *port = state->port;
+       struct uart_port *port;
 
        BUG_ON(!kernel_locked());
+
+       if (!state || !state->port)
+               return;
+
+       port = state->port;
+
        DPRINTK("uart_close(%d) called\n", port->line);
 
        down(&state->sem);