[PATCH] dmaengine: qcom_hidma: Fix runtime PM leak in hidma_issue_task()

Wentao Liang posted 1 patch 1 week, 1 day ago
drivers/dma/qcom/hidma.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
[PATCH] dmaengine: qcom_hidma: Fix runtime PM leak in hidma_issue_task()
Posted by Wentao Liang 1 week, 1 day ago
hidma_issue_task() bumps the device usage counter with
pm_runtime_get_sync() without checking the return value. The counter
is incremented even when the resume fails, e.g. when runtime PM has
been disabled or the device is suspending, and nothing drops it in
that case, so each failure leaves the device with an elevated usage
count and it can no longer runtime suspend.

Bail out and drop the leaked increment with pm_runtime_put_noidle()
when the resume fails, and only start the transfer when the device is
actually resumed. The counter for a successful resume is still
dropped by hidma_callback() as before.

Fixes: 67a2003e0607 ("dmaengine: add Qualcomm Technologies HIDMA channel driver")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/dma/qcom/hidma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/qcom/hidma.c b/drivers/dma/qcom/hidma.c
index 5a8dca8db5ce..03a73dc9b066 100644
--- a/drivers/dma/qcom/hidma.c
+++ b/drivers/dma/qcom/hidma.c
@@ -220,7 +220,10 @@ static void hidma_issue_task(struct tasklet_struct *t)
 {
 	struct hidma_dev *dmadev = from_tasklet(dmadev, t, task);
 
-	pm_runtime_get_sync(dmadev->ddev.dev);
+	if (pm_runtime_get_sync(dmadev->ddev.dev) < 0) {
+		pm_runtime_put_noidle(dmadev->ddev.dev);
+		return;
+	}
 	hidma_ll_start(dmadev->lldev);
 }
 
-- 
2.34.1
Re: [PATCH] dmaengine: qcom_hidma: Fix runtime PM leak in hidma_issue_task()
Posted by Frank Li 1 week, 1 day ago
On Wed, Sep 16, 2026 at 09:30:32AM +0000, Wentao Liang wrote:
> [You don't often get email from vulab@iscas.ac.cn. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> hidma_issue_task() bumps the device usage counter with
> pm_runtime_get_sync() without checking the return value. The counter
> is incremented even when the resume fails, e.g. when runtime PM has
> been disabled or the device is suspending, and nothing drops it in
> that case, so each failure leaves the device with an elevated usage
> count and it can no longer runtime suspend.
>
> Bail out and drop the leaked increment with pm_runtime_put_noidle()
> when the resume fails, and only start the transfer when the device is
> actually resumed. The counter for a successful resume is still
> dropped by hidma_callback() as before.
>
> Fixes: 67a2003e0607 ("dmaengine: add Qualcomm Technologies HIDMA channel driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  drivers/dma/qcom/hidma.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/qcom/hidma.c b/drivers/dma/qcom/hidma.c
> index 5a8dca8db5ce..03a73dc9b066 100644
> --- a/drivers/dma/qcom/hidma.c
> +++ b/drivers/dma/qcom/hidma.c
> @@ -220,7 +220,10 @@ static void hidma_issue_task(struct tasklet_struct *t)
>  {
>         struct hidma_dev *dmadev = from_tasklet(dmadev, t, task);
>
> -       pm_runtime_get_sync(dmadev->ddev.dev);
> +       if (pm_runtime_get_sync(dmadev->ddev.dev) < 0) {

use pm_runtime_resume_and_get()

Frank

> +               pm_runtime_put_noidle(dmadev->ddev.dev);
> +               return;
> +       }
>         hidma_ll_start(dmadev->lldev);
>  }
>
> --
> 2.34.1
>