Re: [PATCH V2 1/8] dmaengine: zynqmp_dma: Fix PM rollback on sw_desc_pool alloc failure
Frank Li <[email protected]>
| Newsgroups | org.kernel.vger.dmaengine,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <an9COy3szB75cgPx@SMW015318> |
On Fri, Aug 14, 2026 at 10:26:09AM +0530, Golla Nagendra wrote:
> If sw_desc_pool allocation fails after pm_runtime_resume_and_get()
> succeeds in zynqmp_dma_alloc_chan_resources(), the error path returns
> without dropping the runtime PM reference.
>
> Route that failure path through err_pm so the runtime PM reference is
> balanced before returning the error.
>
> Fixes: 8982d48af36d ("dmaengine: zynqmp_dma: Fix PM reference leak in zynqmp_dma_alloc_chan_resourc()")
> Signed-off-by: Golla Nagendra <[email protected]>
> ---
Reviewed-by: Frank Li <[email protected]>
> changes in v2:
> - Reworked the patch so sw_desc_pool allocation failure goes through
> err_pm, ensuring the runtime PM reference is dropped before returning
> the error
> - Updated commit description to match the new behavior
> ---
> drivers/dma/xilinx/zynqmp_dma.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
> index f6a812e49ddc..9f1e69700dd0 100644
> --- a/drivers/dma/xilinx/zynqmp_dma.c
> +++ b/drivers/dma/xilinx/zynqmp_dma.c
> @@ -483,8 +483,10 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan)
> return ret;
>
> chan->sw_desc_pool = kzalloc_objs(*desc, ZYNQMP_DMA_NUM_DESCS);
> - if (!chan->sw_desc_pool)
> - return -ENOMEM;
> + if (!chan->sw_desc_pool) {
> + ret = -ENOMEM;
> + goto err_pm;
> + }
>
> chan->idle = true;
> chan->desc_free_cnt = ZYNQMP_DMA_NUM_DESCS;
> @@ -516,6 +518,10 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan)
> }
>
> return ZYNQMP_DMA_NUM_DESCS;
> +
> +err_pm:
> + pm_runtime_put_autosuspend(chan->dev);
> + return ret;
> }
>
> /**
> --
> 2.44.4
>