]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
serial: fsl_lpuart: Reset prior to registration
authorLukas Wunner <lukas@wunner.de>
Sun, 11 Sep 2022 08:22:01 +0000 (10:22 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Sep 2022 14:37:59 +0000 (16:37 +0200)
Since commit bd5305dcabbc ("tty: serial: fsl_lpuart: do software reset
for imx7ulp and imx8qxp"), certain i.MX UARTs are reset after they've
already been registered.  Register state may thus be clobbered after
user space has begun to open and access the UART.

Avoid by performing the reset prior to registration.

Fixes: bd5305dcabbc ("tty: serial: fsl_lpuart: do software reset for imx7ulp and imx8qxp")
Cc: stable@vger.kernel.org # v5.15+
Cc: Fugang Duan <fugang.duan@nxp.com>
Cc: Sherry Sun <sherry.sun@nxp.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Link: https://lore.kernel.org/r/72fb646c1b0b11c989850c55f52f9ff343d1b2fa.1662884345.git.lukas@wunner.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/fsl_lpuart.c

index b20f6f2fa51cee9f97613da3bee77128e9c89cba..fbc4b071b3309e0d479bb31c880e1d41486ea15c 100644 (file)
@@ -2724,14 +2724,15 @@ static int lpuart_probe(struct platform_device *pdev)
                lpuart_reg.cons = LPUART_CONSOLE;
                handler = lpuart_int;
        }
-       ret = uart_add_one_port(&lpuart_reg, &sport->port);
-       if (ret)
-               goto failed_attach_port;
 
        ret = lpuart_global_reset(sport);
        if (ret)
                goto failed_reset;
 
+       ret = uart_add_one_port(&lpuart_reg, &sport->port);
+       if (ret)
+               goto failed_attach_port;
+
        ret = uart_get_rs485_mode(&sport->port);
        if (ret)
                goto failed_get_rs485;
@@ -2747,9 +2748,9 @@ static int lpuart_probe(struct platform_device *pdev)
 
 failed_irq_request:
 failed_get_rs485:
-failed_reset:
        uart_remove_one_port(&lpuart_reg, &sport->port);
 failed_attach_port:
+failed_reset:
        lpuart_disable_clks(sport);
        return ret;
 }