DMA Engine development
 help / color / mirror / Atom feed
* [PATCH] dmaengine: sprd: fix clock imbalance when enabling ashb_clk fails
@ 2026-08-13 10:53 Chaithanya Lagisetty
  2026-08-13 11:06 ` sashiko-bot
  2026-08-13 16:39 ` Frank Li
  0 siblings, 2 replies; 3+ messages in thread
From: Chaithanya Lagisetty @ 2026-08-13 10:53 UTC (permalink / raw)
  To: Vinod Koul, Orson Zhai, Baolin Wang, Chunyan Zhang
  Cc: Frank Li, Chaithanya Lagisetty, dmaengine, linux-kernel

sprd_dma_enable() enables sdev->clk and then enables the optional
ashb_clk. If clk_prepare_enable() for ashb_clk fails, the function
returns the error without disabling sdev->clk, which was already
enabled. Both callers (probe and resume) treat a non-zero return as
"nothing was enabled" and bail out, so sdev->clk is leaked.

Disable sdev->clk on the ashb_clk enable failure path.

Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
Signed-off-by: Chaithanya Lagisetty <nagachaithanya9911@gmail.com>
---
 drivers/dma/sprd-dma.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index 087fea3af2e4..3ea5c3ba1a8c 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -270,9 +270,16 @@ static int sprd_dma_enable(struct sprd_dma_dev *sdev)
 	 * The ashb_clk is optional and only for AGCP DMA controller, so we
 	 * need add one condition to check if the ashb_clk need enable.
 	 */
-	if (!IS_ERR(sdev->ashb_clk))
+	if (!IS_ERR(sdev->ashb_clk)) {
 		ret = clk_prepare_enable(sdev->ashb_clk);
+		if (ret)
+			goto disable_clk;
+	}
 
+	return 0;
+
+disable_clk:
+	clk_disable_unprepare(sdev->clk);
 	return ret;
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-13 16:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 10:53 [PATCH] dmaengine: sprd: fix clock imbalance when enabling ashb_clk fails Chaithanya Lagisetty
2026-08-13 11:06 ` sashiko-bot
2026-08-13 16:39 ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox