* [PATCH] dmaengine: sprd: Fix runtime PM reference leak in probe
@ 2026-08-13 15:31 Ruoyu Wang
2026-08-14 0:35 ` Baolin Wang
2026-08-19 19:29 ` Frank Li
0 siblings, 2 replies; 3+ messages in thread
From: Ruoyu Wang @ 2026-08-13 15:31 UTC (permalink / raw)
To: dmaengine
Cc: vkoul, Frank.Li, orsonzhai, baolin.wang, zhang.lyra,
linux-kernel, Ruoyu Wang
pm_runtime_get_sync() increments a device's usage counter even when it
fails. sprd_dma_probe() currently jumps directly to controller clock
cleanup on that error, bypassing both pm_runtime_put_noidle() and
pm_runtime_disable(). This can happen if the preceding unchecked
pm_runtime_set_active() fails and the following runtime-resume attempt
also returns an error.
Enter the existing runtime-PM unwind path instead. This drops the
reference without idling the partially initialized device, disables
runtime PM, and then releases the controller clocks. The success path
and propagated error code are unchanged.
This issue was found by a static analysis checker and confirmed by manual
source review.
Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
drivers/dma/sprd-dma.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index 087fea3af2e411..19b32a23c882de 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -1212,7 +1212,7 @@ static int sprd_dma_probe(struct platform_device *pdev)
ret = pm_runtime_get_sync(&pdev->dev);
if (ret < 0)
- goto err_rpm;
+ goto err_register;
ret = dma_async_device_register(&sdev->dma_dev);
if (ret < 0) {
@@ -1234,7 +1234,6 @@ static int sprd_dma_probe(struct platform_device *pdev)
err_register:
pm_runtime_put_noidle(&pdev->dev);
pm_runtime_disable(&pdev->dev);
-err_rpm:
sprd_dma_disable(sdev);
return ret;
}
--
2.51.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dmaengine: sprd: Fix runtime PM reference leak in probe
2026-08-13 15:31 [PATCH] dmaengine: sprd: Fix runtime PM reference leak in probe Ruoyu Wang
@ 2026-08-14 0:35 ` Baolin Wang
2026-08-19 19:29 ` Frank Li
1 sibling, 0 replies; 3+ messages in thread
From: Baolin Wang @ 2026-08-14 0:35 UTC (permalink / raw)
To: Ruoyu Wang, dmaengine
Cc: vkoul, Frank.Li, orsonzhai, zhang.lyra, linux-kernel
On 8/13/26 11:31 PM, Ruoyu Wang wrote:
> pm_runtime_get_sync() increments a device's usage counter even when it
> fails. sprd_dma_probe() currently jumps directly to controller clock
> cleanup on that error, bypassing both pm_runtime_put_noidle() and
> pm_runtime_disable(). This can happen if the preceding unchecked
> pm_runtime_set_active() fails and the following runtime-resume attempt
> also returns an error.
>
> Enter the existing runtime-PM unwind path instead. This drops the
> reference without idling the partially initialized device, disables
> runtime PM, and then releases the controller clocks. The success path
> and propagated error code are unchanged.
>
> This issue was found by a static analysis checker and confirmed by manual
> source review.
>
> Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
> ---
LGTM. Thanks.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> drivers/dma/sprd-dma.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
> index 087fea3af2e411..19b32a23c882de 100644
> --- a/drivers/dma/sprd-dma.c
> +++ b/drivers/dma/sprd-dma.c
> @@ -1212,7 +1212,7 @@ static int sprd_dma_probe(struct platform_device *pdev)
>
> ret = pm_runtime_get_sync(&pdev->dev);
> if (ret < 0)
> - goto err_rpm;
> + goto err_register;
>
> ret = dma_async_device_register(&sdev->dma_dev);
> if (ret < 0) {
> @@ -1234,7 +1234,6 @@ static int sprd_dma_probe(struct platform_device *pdev)
> err_register:
> pm_runtime_put_noidle(&pdev->dev);
> pm_runtime_disable(&pdev->dev);
> -err_rpm:
> sprd_dma_disable(sdev);
> return ret;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dmaengine: sprd: Fix runtime PM reference leak in probe
2026-08-13 15:31 [PATCH] dmaengine: sprd: Fix runtime PM reference leak in probe Ruoyu Wang
2026-08-14 0:35 ` Baolin Wang
@ 2026-08-19 19:29 ` Frank Li
1 sibling, 0 replies; 3+ messages in thread
From: Frank Li @ 2026-08-19 19:29 UTC (permalink / raw)
To: Ruoyu Wang
Cc: dmaengine, vkoul, Frank.Li, orsonzhai, baolin.wang, zhang.lyra,
linux-kernel
On Thu, Aug 13, 2026 at 11:31:49PM +0800, Ruoyu Wang wrote:
> pm_runtime_get_sync() increments a device's usage counter even when it
> fails. sprd_dma_probe() currently jumps directly to controller clock
> cleanup on that error, bypassing both pm_runtime_put_noidle() and
> pm_runtime_disable(). This can happen if the preceding unchecked
> pm_runtime_set_active() fails and the following runtime-resume attempt
> also returns an error.
>
> Enter the existing runtime-PM unwind path instead. This drops the
> reference without idling the partially initialized device, disables
> runtime PM, and then releases the controller clocks. The success path
> and propagated error code are unchanged.
>
> This issue was found by a static analysis checker and confirmed by manual
> source review.
>
> Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/dma/sprd-dma.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
> index 087fea3af2e411..19b32a23c882de 100644
> --- a/drivers/dma/sprd-dma.c
> +++ b/drivers/dma/sprd-dma.c
> @@ -1212,7 +1212,7 @@ static int sprd_dma_probe(struct platform_device *pdev)
>
> ret = pm_runtime_get_sync(&pdev->dev);
> if (ret < 0)
> - goto err_rpm;
> + goto err_register;
>
> ret = dma_async_device_register(&sdev->dma_dev);
> if (ret < 0) {
> @@ -1234,7 +1234,6 @@ static int sprd_dma_probe(struct platform_device *pdev)
> err_register:
> pm_runtime_put_noidle(&pdev->dev);
> pm_runtime_disable(&pdev->dev);
> -err_rpm:
> sprd_dma_disable(sdev);
> return ret;
> }
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-19 19:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-13 15:31 [PATCH] dmaengine: sprd: Fix runtime PM reference leak in probe Ruoyu Wang
2026-08-14 0:35 ` Baolin Wang
2026-08-19 19:29 ` Frank Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®