[PATCH 4/4] dmaengine: rcar-dmac: Fix runtime PM leak in error path of channel alloc

From: Wentao Liang

Date: Mon Sep 14 2026 - 23:56:52 EST


rcar_dmac_alloc_chan_resources() ends with
"return pm_runtime_get_sync(chan->device->dev);". Even when
pm_runtime_get_sync() fails, it leaves the device's runtime PM
usage count incremented, and the negative return value propagates
straight to the dmaengine core, which aborts the channel
allocation without ever calling device_free_chan_resources(). The
balanced pm_runtime_put() only happens later in
rcar_dmac_free_chan_resources(), so the reference is leaked
whenever resuming the device fails.

Use pm_runtime_resume_and_get() instead, which drops the reference
again on failure and returns 0 on success.

Fixes: 87244fe5abdf ("dmaengine: rcar-dmac: Add Renesas R-Car Gen2 DMA Controller (DMAC) driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/dma/sh/rcar-dmac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 44eab2d21d54..2d2baa36feea 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1068,7 +1068,7 @@ static int rcar_dmac_alloc_chan_resources(struct dma_chan *chan)
if (ret < 0)
return -ENOMEM;

- return pm_runtime_get_sync(chan->device->dev);
+ return pm_runtime_resume_and_get(chan->device->dev);
}

static void rcar_dmac_free_chan_resources(struct dma_chan *chan)
--
2.34.1