提交 b2267a6b 编写于 作者: A Alexandre Courbot 提交者: Paul Mundt

serial: sh-sci: prevent setup of uninitialized serial console

Commit 906b17dc 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: NAlexandre Courbot <gnurou@gmail.com>
Signed-off-by: NPaul Mundt <lethal@linux-sh.org>
上级 ff7690b4
...@@ -1836,6 +1836,12 @@ static int __devinit serial_console_setup(struct console *co, char *options) ...@@ -1836,6 +1836,12 @@ static int __devinit serial_console_setup(struct console *co, char *options)
sci_port = &sci_ports[co->index]; sci_port = &sci_ports[co->index];
port = &sci_port->port; port = &sci_port->port;
/*
* Refuse to handle uninitialized ports.
*/
if (!port->ops)
return -ENODEV;
ret = sci_remap_port(port); ret = sci_remap_port(port);
if (unlikely(ret != 0)) if (unlikely(ret != 0))
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册