]> git.hungrycats.org Git - linux/commitdiff
[PATCH] serial console registration bugfix
authorAndrew Morton <akpm@osdl.org>
Mon, 29 Dec 2003 13:44:25 +0000 (05:44 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Mon, 29 Dec 2003 13:44:25 +0000 (05:44 -0800)
From: Bjorn Helgaas <bjorn.helgaas@hp.com>

uart_set_options() can dereference a null pointer.  This happens if you
specify a console that hasn't previously been setup by early_serial_setup().

For example, on ia64, the HCDP typically tells us about line 0, so we calls
early_serial_setup() for it.  If the user specifies "console=ttyS3", we
machine-check when trying to follow the uninitialized port->ops pointer.

It's not entirely clear to me whether we should return 0 or -ENODEV or
something.  The advantage of returning zero is that if the user specifies
"console=ttyS0" and we just lack the HCDP, the console doesn't work as early
as usual, but it does start working after the serial driver detects the port
(though the baud/parity/etc from the command line are lost).  Returning
-ENODEV seems to prevent it from ever working.

drivers/serial/serial_core.c

index 02821f17036d3c3079e6ea8923a285fa5b157528..89bc311a28fbe4aab73c2cdf566d3ab38ed2a6d0 100644 (file)
@@ -1862,6 +1862,9 @@ uart_set_options(struct uart_port *port, struct console *co,
        if (flow == 'r')
                termios.c_cflag |= CRTSCTS;
 
+       if (!port->ops)
+               return 0;       /* "console=" on ia64 */
+
        port->ops->set_termios(port, &termios, NULL);
        co->cflag = termios.c_cflag;