diff mbox series

[v2,-next,1/3] dmaengine: qcom: bam_dma: fix PM usage counter unbalance in bam_dma

Message ID 20220922131616.104320-1-zhangqilong3@huawei.com (mailing list archive)
State Changes Requested
Headers show
Series [v2,-next,1/3] dmaengine: qcom: bam_dma: fix PM usage counter unbalance in bam_dma | expand

Commit Message

Zhang Qilong Sept. 22, 2022, 1:16 p.m. UTC
pm_runtime_get_sync will increment pm usage counter even it failed.
Forgetting to putting operation will result in reference leak here.
We fix it by replacing it with the newer pm_runtime_resume_and_get
to keep usage counter balanced.

Fixes:0ac9c3dd0d6fe ("dmaengine: qcom: bam_dma: fix runtime PM underflow")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 drivers/dma/qcom/bam_dma.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
index 2ff787df513e..415ad0008f18 100644
--- a/drivers/dma/qcom/bam_dma.c
+++ b/drivers/dma/qcom/bam_dma.c
@@ -573,7 +573,7 @@  static void bam_free_chan(struct dma_chan *chan)
 	unsigned long flags;
 	int ret;
 
-	ret = pm_runtime_get_sync(bdev->dev);
+	ret = pm_runtime_resume_and_get(bdev->dev);
 	if (ret < 0)
 		return;
 
@@ -776,7 +776,7 @@  static int bam_pause(struct dma_chan *chan)
 	unsigned long flag;
 	int ret;
 
-	ret = pm_runtime_get_sync(bdev->dev);
+	ret = pm_runtime_resume_and_get(bdev->dev);
 	if (ret < 0)
 		return ret;
 
@@ -802,7 +802,7 @@  static int bam_resume(struct dma_chan *chan)
 	unsigned long flag;
 	int ret;
 
-	ret = pm_runtime_get_sync(bdev->dev);
+	ret = pm_runtime_resume_and_get(bdev->dev);
 	if (ret < 0)
 		return ret;
 
@@ -911,7 +911,7 @@  static irqreturn_t bam_dma_irq(int irq, void *data)
 	if (srcs & P_IRQ)
 		tasklet_schedule(&bdev->task);
 
-	ret = pm_runtime_get_sync(bdev->dev);
+	ret = pm_runtime_resume_and_get(bdev->dev);
 	if (ret < 0)
 		return IRQ_NONE;
 
@@ -1029,7 +1029,7 @@  static void bam_start_dma(struct bam_chan *bchan)
 	if (!vd)
 		return;
 
-	ret = pm_runtime_get_sync(bdev->dev);
+	ret = pm_runtime_resume_and_get(bdev->dev);
 	if (ret < 0)
 		return;