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

From: Wolfram Sang

Date: Wed Sep 16 2026 - 04:47:54 EST


On Tue, Sep 15, 2026 at 03:56:02AM +0000, Wentao Liang wrote:
> 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>

Thanks for this patch. This is a duplicate of a previously sent patch
which seem to have fallen through the cracks[1]. I will resend the old
patch, but thank you for pointing out the issue again.

[1] https://lore.kernel.org/all/tencent_71CC9630D88A8792C2396A8844DCCD5C6D06@xxxxxx/

Attachment: signature.asc
Description: PGP signature