[PATCH] omap-dma: fix dma_pool resource leak in error paths

Haotian Zhang posted 1 patch 3 months ago
drivers/dma/ti/omap-dma.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] omap-dma: fix dma_pool resource leak in error paths
Posted by Haotian Zhang 3 months ago
The dma_pool created by dma_pool_create() is not destroyed when
dma_async_device_register() or of_dma_controller_register() fails,
causing a resource leak in the probe error paths.

Add dma_pool_destroy() in both error paths to properly release the
allocated dma_pool resource.

Fixes: 7bedaa553760 ("dmaengine: add OMAP DMA engine driver")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 drivers/dma/ti/omap-dma.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c
index 8c023c6e623a..73ed4b794630 100644
--- a/drivers/dma/ti/omap-dma.c
+++ b/drivers/dma/ti/omap-dma.c
@@ -1808,6 +1808,8 @@ static int omap_dma_probe(struct platform_device *pdev)
 	if (rc) {
 		pr_warn("OMAP-DMA: failed to register slave DMA engine device: %d\n",
 			rc);
+		if (od->ll123_supported)
+			dma_pool_destroy(od->desc_pool);
 		omap_dma_free(od);
 		return rc;
 	}
@@ -1823,6 +1825,8 @@ static int omap_dma_probe(struct platform_device *pdev)
 		if (rc) {
 			pr_warn("OMAP-DMA: failed to register DMA controller\n");
 			dma_async_device_unregister(&od->ddev);
+			if (od->ll123_supported)
+				dma_pool_destroy(od->desc_pool);
 			omap_dma_free(od);
 		}
 	}
-- 
2.50.1.windows.1
Re: [PATCH] omap-dma: fix dma_pool resource leak in error paths
Posted by Vinod Koul 1 month, 2 weeks ago
On Mon, 03 Nov 2025 15:30:18 +0800, Haotian Zhang wrote:
> The dma_pool created by dma_pool_create() is not destroyed when
> dma_async_device_register() or of_dma_controller_register() fails,
> causing a resource leak in the probe error paths.
> 
> Add dma_pool_destroy() in both error paths to properly release the
> allocated dma_pool resource.
> 
> [...]

Applied, thanks!

[1/1] omap-dma: fix dma_pool resource leak in error paths
      commit: 7b28c670df4508a7cb1ee31cb159b4366fcc6d4b

Best regards,
-- 
~Vinod