[PATCH v1] dma: at_hdmac: Use stored IRQ in error path

Hongling Zeng posted 1 patch 1 month ago
There is a newer version of this series
drivers/dma/at_hdmac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v1] dma: at_hdmac: Use stored IRQ in error path
Posted by Hongling Zeng 1 month ago
When request_irq() succeeds but a later error occurs in at_dma_probe(),
the error handling path attempts to free the IRQ by calling
platform_get_irq() again instead of using the already stored IRQ number
in the local variable 'irq'.

Use the stored 'irq' variable directly in free_irq() to make the
code clearer and eliminate smatch warnings about potential IRQ leaks.

While platform_get_irq() is deterministic, using the stored value
makes the error handling more robust against future code changes and
clearly shows the relationship between request_irq() and free_irq().

Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
---
Changes in v1:
  - Update commit message
  - Remove Fixes: tag per reviewer feedback
---
---
 drivers/dma/at_hdmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index e5b30a57c477..2a860679b9e1 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -2109,7 +2109,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
 err_memset_pool_create:
 	dma_pool_destroy(atdma->lli_pool);
 err_desc_pool_create:
-	free_irq(platform_get_irq(pdev, 0), atdma);
+	free_irq(irq, atdma);
 err_irq:
 	clk_disable_unprepare(atdma->clk);
 	return err;
-- 
2.25.1
Re: [PATCH v1] dma: at_hdmac: Use stored IRQ in error path
Posted by Frank Li 1 month ago
On Sat, May 09, 2026 at 09:58:12AM +0800, Hongling Zeng wrote:
> When request_irq() succeeds but a later error occurs in at_dma_probe(),
> the error handling path attempts to free the IRQ by calling
> platform_get_irq() again instead of using the already stored IRQ number
> in the local variable 'irq'.
>
> Use the stored 'irq' variable directly in free_irq() to make the
> code clearer and eliminate smatch warnings about potential IRQ leaks.
>
> While platform_get_irq() is deterministic, using the stored value
> makes the error handling more robust against future code changes and
> clearly shows the relationship between request_irq() and free_irq().
>
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

> Changes in v1:
>   - Update commit message
>   - Remove Fixes: tag per reviewer feedback
> ---
> ---
>  drivers/dma/at_hdmac.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
> index e5b30a57c477..2a860679b9e1 100644
> --- a/drivers/dma/at_hdmac.c
> +++ b/drivers/dma/at_hdmac.c
> @@ -2109,7 +2109,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
>  err_memset_pool_create:
>  	dma_pool_destroy(atdma->lli_pool);
>  err_desc_pool_create:
> -	free_irq(platform_get_irq(pdev, 0), atdma);
> +	free_irq(irq, atdma);
>  err_irq:
>  	clk_disable_unprepare(atdma->clk);
>  	return err;
> --
> 2.25.1
>