]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dmaengine: omap-dma: fix dma_pool resource leak in error paths
authorHaotian Zhang <vulab@iscas.ac.cn>
Mon, 3 Nov 2025 07:30:18 +0000 (15:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Jan 2026 10:18:42 +0000 (11:18 +0100)
[ Upstream commit 2e1136acf8a8887c29f52e35a77b537309af321f ]

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>
Link: https://patch.msgid.link/20251103073018.643-1-vulab@iscas.ac.cn
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/dma/ti/omap-dma.c

index 6ab9bfbdc4809e95d74576a488f81cbf6c4983ac..d0c2fd5c620741733cb4f78735ea21364df35f03 100644 (file)
@@ -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);
                }
        }