serial_core: Unregister console in uart_remove_one_port()
authorGeert Uytterhoeven <geert+renesas@linux-m68k.org>
Fri, 28 Feb 2014 13:21:32 +0000 (14:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Mar 2014 00:39:38 +0000 (16:39 -0800)
If the serial port being removed is used as a console, it must also be
unregistered from the console subsystem using unregister_console().

uart_ops.release_port() will release resources (e.g. iounmap() the serial
port registers), causing a crash on subsequent kernel output if the console
is still registered.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/serial_core.c

index ece2049bd27016487aef8327eee7fb040ee346db..8ece7f14d89d402e4622c3a86b4cdcce0f77417e 100644 (file)
@@ -2676,6 +2676,12 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *uport)
        if (port->tty)
                tty_vhangup(port->tty);
 
+       /*
+        * If the port is used as a console, unregister it
+        */
+       if (uart_console(uport))
+               unregister_console(uport->cons);
+
        /*
         * Free the port IO and memory resources, if any.
         */