From: Greg Kroah-Hartman Date: Fri, 25 Sep 2020 12:38:50 +0000 (+0200) Subject: 4.14-stable patches X-Git-Tag: v4.19.148~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4436b3ac993317402742f247e9a07af9641a374f;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: serial-8250-avoid-error-message-on-reprobe.patch --- diff --git a/queue-4.14/serial-8250-avoid-error-message-on-reprobe.patch b/queue-4.14/serial-8250-avoid-error-message-on-reprobe.patch new file mode 100644 index 00000000000..fa46c680214 --- /dev/null +++ b/queue-4.14/serial-8250-avoid-error-message-on-reprobe.patch @@ -0,0 +1,76 @@ +From e0a851fe6b9b619527bd928aa93caaddd003f70c Mon Sep 17 00:00:00 2001 +From: Lukas Wunner +Date: Tue, 12 May 2020 14:40:01 +0200 +Subject: serial: 8250: Avoid error message on reprobe + +From: Lukas Wunner + +commit e0a851fe6b9b619527bd928aa93caaddd003f70c upstream. + +If the call to uart_add_one_port() in serial8250_register_8250_port() +fails, a half-initialized entry in the serial_8250ports[] array is left +behind. + +A subsequent reprobe of the same serial port causes that entry to be +reused. Because uart->port.dev is set, uart_remove_one_port() is called +for the half-initialized entry and bails out with an error message: + +bcm2835-aux-uart 3f215040.serial: Removing wrong port: (null) != (ptrval) + +The same happens on failure of mctrl_gpio_init() since commit +4a96895f74c9 ("tty/serial/8250: use mctrl_gpio helpers"). + +Fix by zeroing the uart->port.dev pointer in the probe error path. + +The bug was introduced in v2.6.10 by historical commit befff6f5bf5f +("[SERIAL] Add new port registration/unregistration functions."): +https://git.kernel.org/tglx/history/c/befff6f5bf5f + +The commit added an unconditional call to uart_remove_one_port() in +serial8250_register_port(). In v3.7, commit 835d844d1a28 ("8250_pnp: +do pnp probe before legacy probe") made that call conditional on +uart->port.dev which allows me to fix the issue by zeroing that pointer +in the error path. Thus, the present commit will fix the problem as far +back as v3.7 whereas still older versions need to also cherry-pick +835d844d1a28. + +Fixes: 835d844d1a28 ("8250_pnp: do pnp probe before legacy probe") +Signed-off-by: Lukas Wunner +Cc: stable@vger.kernel.org # v2.6.10 +Cc: stable@vger.kernel.org # v2.6.10: 835d844d1a28: 8250_pnp: do pnp probe before legacy +Reviewed-by: Andy Shevchenko +Link: https://lore.kernel.org/r/b4a072013ee1a1d13ee06b4325afb19bda57ca1b.1589285873.git.lukas@wunner.de +[iwamatsu: Backported to 4.14, 4.19: adjust context] +Signed-off-by: Nobuhiro Iwamatsu (CIP) +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/8250/8250_core.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +--- a/drivers/tty/serial/8250/8250_core.c ++++ b/drivers/tty/serial/8250/8250_core.c +@@ -1065,8 +1065,10 @@ int serial8250_register_8250_port(struct + serial8250_apply_quirks(uart); + ret = uart_add_one_port(&serial8250_reg, + &uart->port); +- if (ret == 0) +- ret = uart->port.line; ++ if (ret) ++ goto err; ++ ++ ret = uart->port.line; + } else { + dev_info(uart->port.dev, + "skipping CIR port at 0x%lx / 0x%llx, IRQ %d\n", +@@ -1091,6 +1093,11 @@ int serial8250_register_8250_port(struct + mutex_unlock(&serial_mutex); + + return ret; ++ ++err: ++ uart->port.dev = NULL; ++ mutex_unlock(&serial_mutex); ++ return ret; + } + EXPORT_SYMBOL(serial8250_register_8250_port); + diff --git a/queue-4.14/series b/queue-4.14/series index 9256831f82b..0925e34e0f4 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -14,3 +14,4 @@ net-phy-avoid-npd-upon-phy_detach-when-driver-is-unbound.patch net-add-__must_check-to-skb_put_padto.patch ipv4-update-exception-handling-for-multipath-routes-via-same-device.patch geneve-add-transport-ports-in-route-lookup-for-geneve.patch +serial-8250-avoid-error-message-on-reprobe.patch