Skip to content

Commit

Permalink
serial: sh-sci: prevent setup of uninitialized serial console
Browse files Browse the repository at this point in the history
Commit 906b17d 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 <gnurou@gmail.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
  • Loading branch information
Alexandre Courbot authored and Paul Mundt committed Mar 31, 2011
1 parent ff7690b commit b2267a6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/tty/serial/sh-sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b2267a6

Please sign in to comment.