* [PATCH 1/3] dmaengine: stm32-dma: fix reference leak in stm32_dma
2020-11-27 9:45 [PATCH 0/3] dmaengine: stm32: fix reference leak Qinglang Miao
@ 2020-11-27 9:45 ` Qinglang Miao
2020-11-27 9:45 ` [PATCH 2/3] dmaengine: stm32-dmamux: fix reference leak in stm32_dmamux Qinglang Miao
2020-11-27 9:45 ` [PATCH 3/3] dmaengine: stm32-mdma: fix reference leak in stm32-mdma Qinglang Miao
2 siblings, 0 replies; 4+ messages in thread
From: Qinglang Miao @ 2020-11-27 9:45 UTC (permalink / raw)
To: Vinod Koul, Dan Williams, Maxime Coquelin, Alexandre Torgue
Cc: dmaengine, linux-stm32, linux-arm-kernel, linux-kernel, Qinglang Miao
pm_runtime_get_sync will increment pm usage counter even it
failed. Forgetting to putting operation will result in a
reference leak here.
A new function pm_runtime_resume_and_get is introduced in
[0] to keep usage counter balanced. So We fix the reference
leak by replacing it with new funtion.
[0] dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
Fixes: 05f8740a0e6f ("dmaengine: stm32-dma: add suspend/resume power management support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
drivers/dma/stm32-dma.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index d0055d2f0..1150aa90e 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -1187,7 +1187,7 @@ static int stm32_dma_alloc_chan_resources(struct dma_chan *c)
chan->config_init = false;
- ret = pm_runtime_get_sync(dmadev->ddev.dev);
+ ret = pm_runtime_resume_and_get(dmadev->ddev.dev);
if (ret < 0)
return ret;
@@ -1455,7 +1455,7 @@ static int stm32_dma_suspend(struct device *dev)
struct stm32_dma_device *dmadev = dev_get_drvdata(dev);
int id, ret, scr;
- ret = pm_runtime_get_sync(dev);
+ ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
return ret;
--
2.23.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] dmaengine: stm32-dmamux: fix reference leak in stm32_dmamux
2020-11-27 9:45 [PATCH 0/3] dmaengine: stm32: fix reference leak Qinglang Miao
2020-11-27 9:45 ` [PATCH 1/3] dmaengine: stm32-dma: fix reference leak in stm32_dma Qinglang Miao
@ 2020-11-27 9:45 ` Qinglang Miao
2020-11-27 9:45 ` [PATCH 3/3] dmaengine: stm32-mdma: fix reference leak in stm32-mdma Qinglang Miao
2 siblings, 0 replies; 4+ messages in thread
From: Qinglang Miao @ 2020-11-27 9:45 UTC (permalink / raw)
To: Vinod Koul, Dan Williams, Maxime Coquelin, Alexandre Torgue
Cc: dmaengine, linux-stm32, linux-arm-kernel, linux-kernel, Qinglang Miao
pm_runtime_get_sync will increment pm usage counter even it
failed. Forgetting to putting operation will result in a
reference leak here.
A new function pm_runtime_resume_and_get is introduced in
[0] to keep usage counter balanced. So We fix the reference
leak by replacing it with new funtion.
[0] dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
Fixes: f65c2e14b096 ("dmaengine: stm32-dmamux: add suspend/resume power management support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
drivers/dma/stm32-dmamux.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/stm32-dmamux.c b/drivers/dma/stm32-dmamux.c
index a10ccd964..bddd3b23f 100644
--- a/drivers/dma/stm32-dmamux.c
+++ b/drivers/dma/stm32-dmamux.c
@@ -137,7 +137,7 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,
/* Set dma request */
spin_lock_irqsave(&dmamux->lock, flags);
- ret = pm_runtime_get_sync(&pdev->dev);
+ ret = pm_runtime_resume_and_get(&pdev->dev);
if (ret < 0) {
spin_unlock_irqrestore(&dmamux->lock, flags);
goto error;
@@ -336,7 +336,7 @@ static int stm32_dmamux_suspend(struct device *dev)
struct stm32_dmamux_data *stm32_dmamux = platform_get_drvdata(pdev);
int i, ret;
- ret = pm_runtime_get_sync(dev);
+ ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
return ret;
@@ -361,7 +361,7 @@ static int stm32_dmamux_resume(struct device *dev)
if (ret < 0)
return ret;
- ret = pm_runtime_get_sync(dev);
+ ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
return ret;
--
2.23.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] dmaengine: stm32-mdma: fix reference leak in stm32-mdma
2020-11-27 9:45 [PATCH 0/3] dmaengine: stm32: fix reference leak Qinglang Miao
2020-11-27 9:45 ` [PATCH 1/3] dmaengine: stm32-dma: fix reference leak in stm32_dma Qinglang Miao
2020-11-27 9:45 ` [PATCH 2/3] dmaengine: stm32-dmamux: fix reference leak in stm32_dmamux Qinglang Miao
@ 2020-11-27 9:45 ` Qinglang Miao
2 siblings, 0 replies; 4+ messages in thread
From: Qinglang Miao @ 2020-11-27 9:45 UTC (permalink / raw)
To: Vinod Koul, Dan Williams, Maxime Coquelin, Alexandre Torgue
Cc: dmaengine, linux-stm32, linux-arm-kernel, linux-kernel, Qinglang Miao
pm_runtime_get_sync will increment pm usage counter even it
failed. Forgetting to putting operation will result in a
reference leak here.
A new function pm_runtime_resume_and_get is introduced in
[0] to keep usage counter balanced. So We fix the reference
leak by replacing it with new funtion.
[0] dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
Fixes: 7cb819c856d9 ("dmaengine: stm32-mdma: add suspend/resume power management support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
drivers/dma/stm32-mdma.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c
index 08cfbfab8..9d4739237 100644
--- a/drivers/dma/stm32-mdma.c
+++ b/drivers/dma/stm32-mdma.c
@@ -1448,7 +1448,7 @@ static int stm32_mdma_alloc_chan_resources(struct dma_chan *c)
return -ENOMEM;
}
- ret = pm_runtime_get_sync(dmadev->ddev.dev);
+ ret = pm_runtime_resume_and_get(dmadev->ddev.dev);
if (ret < 0)
return ret;
@@ -1714,7 +1714,7 @@ static int stm32_mdma_pm_suspend(struct device *dev)
u32 ccr, id;
int ret;
- ret = pm_runtime_get_sync(dev);
+ ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
return ret;
--
2.23.0
^ permalink raw reply related [flat|nested] 4+ messages in thread