serial: 8250: Unlink uart console ptr if console setup fails
authorPeter Hurley <peter@hurleysoftware.com>
Sun, 10 Jan 2016 22:39:34 +0000 (14:39 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Jan 2016 22:07:04 +0000 (14:07 -0800)
If console setup fails (eg., there is no valid port at that index),
unlink the console ptr; otherwise, when the driver unloads, the
console will be unregistered (even though setup, and thus registration,
failed) and a console disabled message will be printed.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/8250/8250_core.c

index c9720a97a977801f2b82b084c3580f0d1619734c..8031e428894f46aae1ee10ce7efa7717e46746c7 100644 (file)
@@ -597,6 +597,7 @@ static void univ8250_console_write(struct console *co, const char *s,
 static int univ8250_console_setup(struct console *co, char *options)
 {
        struct uart_port *port;
+       int retval;
 
        /*
         * Check whether an invalid uart number has been specified, and
@@ -609,7 +610,10 @@ static int univ8250_console_setup(struct console *co, char *options)
        /* link port to console */
        port->cons = co;
 
-       return serial8250_console_setup(port, options, false);
+       retval = serial8250_console_setup(port, options, false);
+       if (retval != 0)
+               port->cons = NULL;
+       return retval;
 }
 
 /**