From b2267a6b095afb84b5766d6646e581b9054704d9 Mon Sep 17 00:00:00 2001 From: Alexandre Courbot Date: Wed, 9 Feb 2011 03:18:46 +0000 Subject: [PATCH] serial: sh-sci: prevent setup of uninitialized serial console Commit 906b17dc089f7fa87e37a9cfe6ee185efc90e0da introduced a condition where the kernel will crash unless a earlyprintk parameter is specified. Without this parameter, sci_console_init is called during early console setup without any port being initialized, and the kernel crashes a little bit later when uart_set_options attemps to invoke set_termios on a port with an ops member equal to NULL. This patch just checks in sci_console_init that the port is properly initialized, and aborts the early console setup if it is not. Signed-off-by: Alexandre Courbot Signed-off-by: Paul Mundt --- drivers/tty/serial/sh-sci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index eb7958c675a8..264209c32675 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1836,6 +1836,12 @@ static int __devinit serial_console_setup(struct console *co, char *options) sci_port = &sci_ports[co->index]; port = &sci_port->port; + /* + * Refuse to handle uninitialized ports. + */ + if (!port->ops) + return -ENODEV; + ret = sci_remap_port(port); if (unlikely(ret != 0)) return ret; -- 2.34.1