Skip to content

Commit 401fb66

Browse files
Indanzgregkh
authored andcommitted
fsl_lpuart: Don't enable interrupts too early
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: 9d7ee0e ("tty: serial: lpuart: avoid report NULL interrupt") Cc: stable <[email protected]> Signed-off-by: Indan Zupancic <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9361ebf commit 401fb66

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/tty/serial/fsl_lpuart.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,6 +2664,7 @@ static int lpuart_probe(struct platform_device *pdev)
26642664
struct device_node *np = pdev->dev.of_node;
26652665
struct lpuart_port *sport;
26662666
struct resource *res;
2667+
irq_handler_t handler;
26672668
int ret;
26682669

26692670
sport = devm_kzalloc(&pdev->dev, sizeof(*sport), GFP_KERNEL);
@@ -2741,17 +2742,11 @@ static int lpuart_probe(struct platform_device *pdev)
27412742

27422743
if (lpuart_is_32(sport)) {
27432744
lpuart_reg.cons = LPUART32_CONSOLE;
2744-
ret = devm_request_irq(&pdev->dev, sport->port.irq, lpuart32_int, 0,
2745-
DRIVER_NAME, sport);
2745+
handler = lpuart32_int;
27462746
} else {
27472747
lpuart_reg.cons = LPUART_CONSOLE;
2748-
ret = devm_request_irq(&pdev->dev, sport->port.irq, lpuart_int, 0,
2749-
DRIVER_NAME, sport);
2748+
handler = lpuart_int;
27502749
}
2751-
2752-
if (ret)
2753-
goto failed_irq_request;
2754-
27552750
ret = uart_add_one_port(&lpuart_reg, &sport->port);
27562751
if (ret)
27572752
goto failed_attach_port;
@@ -2773,13 +2768,18 @@ static int lpuart_probe(struct platform_device *pdev)
27732768

27742769
sport->port.rs485_config(&sport->port, &sport->port.rs485);
27752770

2771+
ret = devm_request_irq(&pdev->dev, sport->port.irq, handler, 0,
2772+
DRIVER_NAME, sport);
2773+
if (ret)
2774+
goto failed_irq_request;
2775+
27762776
return 0;
27772777

2778+
failed_irq_request:
27782779
failed_get_rs485:
27792780
failed_reset:
27802781
uart_remove_one_port(&lpuart_reg, &sport->port);
27812782
failed_attach_port:
2782-
failed_irq_request:
27832783
lpuart_disable_clks(sport);
27842784
failed_clock_enable:
27852785
failed_out_of_range:

0 commit comments

Comments
 (0)