Skip to contentSkip to conversation

dmaengine: fsl-edma: Fix clk leak on alloc_chan_resources failure

PATCH Applied Zhen Ni 3 participants 4 messages Oct 14, 2025 – Dec 16, 2025

Subsystems (4)
lore
Share & tools
lore

Zhen Ni

author
#0 lore raw

PATCH v4 1/1 dmaengine: fsl-edma: Fix clk leak on alloc_chan_resources failure

When fsl_edma_alloc_chan_resources() fails after clk_prepare_enable(), the error paths only free IRQs and destroy the TCD pool, but forget to call clk_disable_unprepare(). This causes the channel clock to remain enabled, leaking power and resources.

Fix it by disabling the channel clock in the error unwind path.

Fixes d8d4355861d8 ("dmaengine: fsl-edma: add i.MX8ULP edma support")

---
Changes in v2:
- Remove FSL_EDMA_DRV_HAS_CHCLK check
Changes in v3:
- Remove cleanup
Changes in v4:
- Re-send as a new thread

---
 drivers/dma/fsl-edma-common.c | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/fsl-edma-common.c +1 -0
index 4976d7dde080..11655dcc4d6c 100644
@@ -852,6 +852,7 @@ int fsl_edma_alloc_chan_resources(struct dma_chan *chan)
 		free_irq(fsl_chan->txirq, fsl_chan);
 err_txirq:
 	dma_pool_destroy(fsl_chan->tcd_pool);
+	clk_disable_unprepare(fsl_chan->clk);
 
 	return ret;
 }
Signature · 1 line
2.20.1
maintainer Reviewed-by on v4 1/1
#1 lore raw
Quoted 11 lines · Zhen Ni

When fsl_edma_alloc_chan_resources() fails after clk_prepare_enable(), the error paths only free IRQs and destroy the TCD pool, but forget to call clk_disable_unprepare(). This causes the channel clock to remain enabled, leaking power and resources.

Fix it by disabling the channel clock in the error unwind path.

Fixes d8d4355861d8 ("dmaengine: fsl-edma: add i.MX8ULP edma support")
Quoted 26 lines

---
Changes in v2:
- Remove FSL_EDMA_DRV_HAS_CHCLK check
Changes in v3:
- Remove cleanup
Changes in v4:
- Re-send as a new thread

---
 drivers/dma/fsl-edma-common.c | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/fsl-edma-common.c +1 -1
index 4976d7dde080..11655dcc4d6c 100644
@@ -852,6 +852,7 @@ int fsl_edma_alloc_chan_resources(struct dma_chan *chan)
 		free_irq(fsl_chan->txirq, fsl_chan);
 err_txirq:
 	dma_pool_destroy(fsl_chan->tcd_pool);
+	clk_disable_unprepare(fsl_chan->clk);
 
 	return ret;
 }
--

2.20.1

maintainer
#2 lore raw
Quoted 6 lines · Frank Li
Quoted 5 lines · Zhen Ni

When fsl_edma_alloc_chan_resources() fails after clk_prepare_enable(), the error paths only free IRQs and destroy the TCD pool, but forget to call clk_disable_unprepare(). This causes the channel clock to remain enabled, leaking power and resources.

Quoted 8 lines
Quoted 6 lines

Fix it by disabling the channel clock in the error unwind path.

Fixes d8d4355861d8 ("dmaengine: fsl-edma: add i.MX8ULP edma support")

Vinod Koul:

Do you have chance to pickup this small fix patch?

Frank

Quoted 27 lines
Quoted 27 lines

---
Changes in v2:
- Remove FSL_EDMA_DRV_HAS_CHCLK check
Changes in v3:
- Remove cleanup
Changes in v4:
- Re-send as a new thread

---
 drivers/dma/fsl-edma-common.c | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/fsl-edma-common.c +1 -1
index 4976d7dde080..11655dcc4d6c 100644
@@ -852,6 +852,7 @@ int fsl_edma_alloc_chan_resources(struct dma_chan *chan)
 		free_irq(fsl_chan->txirq, fsl_chan);
 err_txirq:
 	dma_pool_destroy(fsl_chan->tcd_pool);
+	clk_disable_unprepare(fsl_chan->clk);
 
 	return ret;
 }
--

2.20.1

maintainer Applied
#3 lore raw
In reply to Zhen Ni
Quoted 8 lines · Zhen Ni

When fsl_edma_alloc_chan_resources() fails after clk_prepare_enable(), the error paths only free IRQs and destroy the TCD pool, but forget to call clk_disable_unprepare(). This causes the channel clock to remain enabled, leaking power and resources.

Fix it by disabling the channel clock in the error unwind path.

[...]

Applied, thanks!

[1/1] dmaengine: fsl-edma: Fix clk leak on alloc_chan_resources failure

      commit: b18cd8b210417f90537d914ffb96e390c85a7379

Best regards,

Signature · 1 line
~Vinod