serial: ucc_uart: Use platform IRQ helper
PATCH 1/1 serial: ucc_uart: Use platform IRQ helper
Avoid calling irq_dispose_mapping() by letting the platform_device machinery handle it. Also enable possibility of handling -EPROBE_DEFER and other errors. Handle before any allocation or anything to avoid dealing with gotos.
--- drivers/tty/serial/ucc_uart.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/tty/serial/ucc_uart.c +6 -7
@@ -1238,6 +1238,7 @@ static int ucc_uart_probe(struct platform_device *ofdev)struct uart_qe_port *qe_port =NULL ;struct resource res;u32 val; +int irq;int ret;/*
@@ -1247,6 +1248,10 @@ static int ucc_uart_probe(struct platform_device *ofdev)if (ret)return ret; + irq =platform_get_irq (ofdev,0 ); +if (irq <0 ) +return irq; + qe_port = kzalloc_obj(struct uart_qe_port);if (!qe_port) {dev_err (&ofdev->dev,"can't allocate QE port structure\n" );
@@ -1338,13 +1343,7 @@ static int ucc_uart_probe(struct platform_device *ofdev) goto out_free; } - qe_port->port.irq =irq_of_parse_and_map (np,0 ); -if (qe_port->port.irq ==0 ) { -dev_err (&ofdev->dev,"could not map IRQ for UCC%u\n" , - qe_port->ucc_num +1 ); - ret = -EINVAL ; - goto out_free; - } + qe_port->port.irq = irq;/* * Newer device trees have an "fsl,qe" compatible property for the QE
Signature · 1 line
2.55.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] probe deferral: leak of async firmware load due to platform_get_irq() ordering --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] probe deferral: leak of async firmware load due to platform_get_irq() ordering --
commit 887c64b890c9273da1e7e1715e89bca754adbfb0
Author: Rosen Penev <[email protected]>
serial: ucc_uart: Use platform IRQ helper
This commit updates the driver to use platform_get_irq() instead of irq_of_parse_and_map() to obtain the IRQ. The IRQ lookup is moved earlier in the probe function to simplify error handling and explicitly handle probe deferral.
Quoted 13 lines
drivers/tty/serial/ucc_uart.c +1
-0@@ -1238,6 +1238,7 @@ static int ucc_uart_probe(struct platform_device *ofdev)struct uart_qe_port *qe_port =NULL ;struct resource res;u32 val; +int irq;int ret;/*
drivers/tty/serial/ucc_uart.c static int ucc_uart_probe(struct platform_device *ofdev) · line 1254
Quoted 7 lines
drivers/tty/serial/ucc_uart.c +4
-0@@ -1247,6 +1248,10 @@ static int ucc_uart_probe(struct platform_device *ofdev)if (ret)return ret; + irq =platform_get_irq (ofdev,0 ); +if (irq <0 ) +return irq; +
[Severity: High]
If platform_get_irq() returns -EPROBE_DEFER here, does this leak the asynchronous firmware load initiated by the preceding call to soft_uart_init()?
Looking at soft_uart_init(), an async load is triggered like this:
ret = request_firmware_nowait(THIS_MODULE,
FW_ACTION_UEVENT, filename, &ofdev->dev,
GFP_KERNEL, &ofdev->dev, uart_firmware_cont);Since the async firmware load is not cancelled on probe deferral, the probe will eventually be retried and will call soft_uart_init() a second time.
Could this lead to duplicated asynchronous firmware loads and concurrent execution of qe_upload_firmware() upon probe retry, potentially causing data races or hardware state corruption?
Would it make sense to move platform_get_irq() even earlier in the probe function, before soft_uart_init(), to prevent this probe deferral side effect?
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 31 lines · On Fri, Sep 25, 2026 at 11:33 AM <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] probe deferral: leak of async firmware load due toplatform_get_irq()ordering --commit
887c64b890c9273da1e7e1715e89bca754adbfb0
Author: Rosen Penev <[email protected]>serial:
ucc_uart: Use platform IRQ helperThis commit updates the driver to use
platform_get_irq()instead ofirq_of_parse_and_map()to obtain the IRQ. The IRQ lookup is moved earlier in the probe function to simplify error handling and explicitly handle probe deferral.Quoted 16 lines
drivers/tty/serial/ucc_uart.c +1
-0@@ -1238,6 +1238,7 @@ static int ucc_uart_probe(struct platform_device *ofdev)struct uart_qe_port *qe_port =NULL ;struct resource res;u32 val; +int irq;int ret;/* @@ -1247,6 +1248,10 @@ static int ucc_uart_probe(struct platform_device *ofdev)if (ret)return ret;
Quoted 9 lines
drivers/tty/serial/ucc_uart.c static int ucc_uart_probe(struct platform_device *ofdev) · line 1254
Quoted 4 lines
drivers/tty/serial/ucc_uart.c +4
-0+ irq =platform_get_irq (ofdev,0 ); +if (irq <0 ) +return irq; +[Severity: High]
Ifplatform_get_irq()returns -EPROBE_DEFER here, does this leak the asynchronous firmware load initiated by the preceding call tosoft_uart_init()?
That's pre-existing.
Quoted 10 lines
Looking at
soft_uart_init(), an async load is triggered like this:ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_UEVENT, filename, &ofdev->dev, GFP_KERNEL, &ofdev->dev, uart_firmware_cont);Since the async firmware load is not cancelled on probe deferral, the probe will eventually be retried and will call
soft_uart_init()a second time.
Quoted 7 lines
Could this lead to duplicated asynchronous firmware loads and concurrent execution of
qe_upload_firmware()upon probe retry, potentially causing data races or hardware state corruption?Would it make sense to move
platform_get_irq()even earlier in the probe function, beforesoft_uart_init(), to prevent this probe deferral side effect?
Yes
Quoted 5 lines
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1