Commit 59cfc45f authored by Jan Kiszka's avatar Jan Kiszka Committed by Greg Kroah-Hartman

serial: 8250: Do nothing if nr_uarts=0

When nr_uarts was set to 0 (via config or 8250_core.nr_uarts), we crash
early on x86 because serial8250_isa_init_ports dereferences base_ops
which remains NULL. In fact, there is nothing to do for all the callers
of serial8250_isa_init_ports if there are no uarts.

Based on suggestions by Peter Hurley.
Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 24ee4df1
...@@ -3535,6 +3535,9 @@ static struct console univ8250_console = { ...@@ -3535,6 +3535,9 @@ static struct console univ8250_console = {
static int __init univ8250_console_init(void) static int __init univ8250_console_init(void)
{ {
if (nr_uarts == 0)
return -ENODEV;
serial8250_isa_init_ports(); serial8250_isa_init_ports();
register_console(&univ8250_console); register_console(&univ8250_console);
return 0; return 0;
...@@ -3565,7 +3568,7 @@ int __init early_serial_setup(struct uart_port *port) ...@@ -3565,7 +3568,7 @@ int __init early_serial_setup(struct uart_port *port)
{ {
struct uart_port *p; struct uart_port *p;
if (port->line >= ARRAY_SIZE(serial8250_ports)) if (port->line >= ARRAY_SIZE(serial8250_ports) || nr_uarts == 0)
return -ENODEV; return -ENODEV;
serial8250_isa_init_ports(); serial8250_isa_init_ports();
...@@ -3932,6 +3935,9 @@ static int __init serial8250_init(void) ...@@ -3932,6 +3935,9 @@ static int __init serial8250_init(void)
{ {
int ret; int ret;
if (nr_uarts == 0)
return -ENODEV;
serial8250_isa_init_ports(); serial8250_isa_init_ports();
printk(KERN_INFO "Serial: 8250/16550 driver, " printk(KERN_INFO "Serial: 8250/16550 driver, "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment