Commit 98642bc0 authored by Indan Zupancic's avatar Indan Zupancic Committed by zhaoxiaoqiang11
Browse files

fsl_lpuart: Don't enable interrupts too early

stable inclusion
from stable-v5.10.163
commit 2ecf0819e441c074e18c543bcdb8a6f48cc98d3f
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7PJ9N

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2ecf0819e441c074e18c543bcdb8a6f48cc98d3f



----------------------------------------------------

commit 401fb66a upstream.

If an irq is pending when devm_request_irq() is called, the irq
handler will cause a NULL pointer access because initialisation
is not done yet.

Fixes: 9d7ee0e2 ("tty: serial: lpuart: avoid report NULL interrupt")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: default avatarIndan Zupancic <Indan.Zupancic@mep-info.com>
Link: https://lore.kernel.org/r/20220505114750.45423-1-Indan.Zupancic@mep-info.com


[5.10 did not have lpuart_global_reset or anything after
uart_add_one_port(), so add the remove call in cleanup manually]
Signed-off-by: default avatarDominique Martinet <dominique.martinet@atmark-techno.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarzhaoxiaoqiang11 <zhaoxiaoqiang11@jd.com>
parent ce398d1d
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -2586,6 +2586,7 @@ static int lpuart_probe(struct platform_device *pdev)
	struct device_node *np = pdev->dev.of_node;
	struct lpuart_port *sport;
	struct resource *res;
	irq_handler_t handler;
	int ret;

	sport = devm_kzalloc(&pdev->dev, sizeof(*sport), GFP_KERNEL);
@@ -2658,17 +2659,12 @@ static int lpuart_probe(struct platform_device *pdev)

	if (lpuart_is_32(sport)) {
		lpuart_reg.cons = LPUART32_CONSOLE;
		ret = devm_request_irq(&pdev->dev, sport->port.irq, lpuart32_int, 0,
					DRIVER_NAME, sport);
		handler = lpuart32_int;
	} else {
		lpuart_reg.cons = LPUART_CONSOLE;
		ret = devm_request_irq(&pdev->dev, sport->port.irq, lpuart_int, 0,
					DRIVER_NAME, sport);
		handler = lpuart_int;
	}

	if (ret)
		goto failed_irq_request;

	ret = uart_get_rs485_mode(&sport->port);
	if (ret)
		goto failed_get_rs485;
@@ -2684,11 +2680,17 @@ static int lpuart_probe(struct platform_device *pdev)
	if (ret)
		goto failed_attach_port;

	ret = devm_request_irq(&pdev->dev, sport->port.irq, handler, 0,
				DRIVER_NAME, sport);
	if (ret)
		goto failed_irq_request;

	return 0;

failed_irq_request:
	uart_remove_one_port(&lpuart_reg, &sport->port);
failed_get_rs485:
failed_attach_port:
failed_irq_request:
	lpuart_disable_clks(sport);
	return ret;
}