From 78980490d185bb58e26bb4c81ee5a6e697ee7e2c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 22 Mar 2013 14:03:46 -0700 Subject: [PATCH] 3.8-stable patches added patches: sunsu-fix-panic-in-case-of-nonexistent-port-at-console-ttysy-cmdline-option.patch --- queue-3.8/series | 1 + ...port-at-console-ttysy-cmdline-option.patch | 119 ++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 queue-3.8/sunsu-fix-panic-in-case-of-nonexistent-port-at-console-ttysy-cmdline-option.patch diff --git a/queue-3.8/series b/queue-3.8/series index 533e19574b2..d71ad4f3e5d 100644 --- a/queue-3.8/series +++ b/queue-3.8/series @@ -1 +1,2 @@ usb-ehci-work-around-silicon-bug-in-intel-s-ehci-controllers.patch +sunsu-fix-panic-in-case-of-nonexistent-port-at-console-ttysy-cmdline-option.patch diff --git a/queue-3.8/sunsu-fix-panic-in-case-of-nonexistent-port-at-console-ttysy-cmdline-option.patch b/queue-3.8/sunsu-fix-panic-in-case-of-nonexistent-port-at-console-ttysy-cmdline-option.patch new file mode 100644 index 00000000000..476dfd65c44 --- /dev/null +++ b/queue-3.8/sunsu-fix-panic-in-case-of-nonexistent-port-at-console-ttysy-cmdline-option.patch @@ -0,0 +1,119 @@ +From cac1b508065e1c0ed0085f3f33cf058fadea224f Mon Sep 17 00:00:00 2001 +From: Tkhai Kirill +Date: Sat, 23 Feb 2013 23:01:15 +0000 +Subject: sunsu: Fix panic in case of nonexistent port at "console=ttySY" cmdline option + + +From: Tkhai Kirill + +[ Upstream commit cb29529ea0030e60ef1bbbf8399a43d397a51526 ] + +If a machine has X (X < 4) sunsu ports and cmdline +option "console=ttySY" is passed, where X < Y <= 4, +than the following panic happens: + +Unable to handle kernel NULL pointer dereference +TPC: +RPC: +I7: +Call Trace: + [0000000000453a38] register_console+0x378/0x3e0 + [0000000000576fa0] uart_add_one_port+0x2e0/0x340 + [000000000057af40] su_probe+0x160/0x2e0 + [00000000005b8a4c] platform_drv_probe+0xc/0x20 + [00000000005b6c2c] driver_probe_device+0x12c/0x220 + [00000000005b6da8] __driver_attach+0x88/0xa0 + [00000000005b4df4] bus_for_each_dev+0x54/0xa0 + [00000000005b5a54] bus_add_driver+0x154/0x260 + [00000000005b7190] driver_register+0x50/0x180 + [00000000006d250c] sunsu_init+0x18c/0x1e0 + [00000000006c2668] do_one_initcall+0xe8/0x160 + [00000000006c282c] kernel_init_freeable+0x12c/0x1e0 + [0000000000603764] kernel_init+0x4/0x100 + [0000000000405f64] ret_from_syscall+0x1c/0x2c + [0000000000000000] (null) + +1)Fix the panic; +2)Increment registered port number every successful +probe. + +Signed-off-by: Kirill Tkhai +CC: David Miller +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/sunsu.c | 21 +++++++++------------ + 1 file changed, 9 insertions(+), 12 deletions(-) + +--- a/drivers/tty/serial/sunsu.c ++++ b/drivers/tty/serial/sunsu.c +@@ -974,6 +974,7 @@ static struct uart_ops sunsu_pops = { + #define UART_NR 4 + + static struct uart_sunsu_port sunsu_ports[UART_NR]; ++static int nr_inst; /* Number of already registered ports */ + + #ifdef CONFIG_SERIO + +@@ -1343,13 +1344,8 @@ static int __init sunsu_console_setup(st + printk("Console: ttyS%d (SU)\n", + (sunsu_reg.minor - 64) + co->index); + +- /* +- * Check whether an invalid uart number has been specified, and +- * if so, search for the first available port that does have +- * console support. +- */ +- if (co->index >= UART_NR) +- co->index = 0; ++ if (co->index > nr_inst) ++ return -ENODEV; + port = &sunsu_ports[co->index].port; + + /* +@@ -1414,7 +1410,6 @@ static enum su_type su_get_type(struct d + + static int su_probe(struct platform_device *op) + { +- static int inst; + struct device_node *dp = op->dev.of_node; + struct uart_sunsu_port *up; + struct resource *rp; +@@ -1424,16 +1419,16 @@ static int su_probe(struct platform_devi + + type = su_get_type(dp); + if (type == SU_PORT_PORT) { +- if (inst >= UART_NR) ++ if (nr_inst >= UART_NR) + return -EINVAL; +- up = &sunsu_ports[inst]; ++ up = &sunsu_ports[nr_inst]; + } else { + up = kzalloc(sizeof(*up), GFP_KERNEL); + if (!up) + return -ENOMEM; + } + +- up->port.line = inst; ++ up->port.line = nr_inst; + + spin_lock_init(&up->port.lock); + +@@ -1467,6 +1462,8 @@ static int su_probe(struct platform_devi + } + dev_set_drvdata(&op->dev, up); + ++ nr_inst++; ++ + return 0; + } + +@@ -1494,7 +1491,7 @@ static int su_probe(struct platform_devi + + dev_set_drvdata(&op->dev, up); + +- inst++; ++ nr_inst++; + + return 0; + -- 2.47.3