2020-11-27 09:44:43

by Qinglang Miao

[permalink] [raw]
Subject: [PATCH 0/3] dmaengine: stm32: fix reference leak

pm_runtime_get_sync will increment pm usage counter even it
failed. Forgetting to putting operation will result in a
reference leak here.

Use pm_runtime_resume_and_get to fix it.

Qinglang Miao (3):
dmaengine: stm32-dma: fix reference leak in stm32_dma
dmaengine: stm32-dmamux: fix reference leak in stm32_dmamux
dmaengine: stm32-mdma: fix reference leak in stm32-mdma

drivers/dma/stm32-dma.c | 4 ++--
drivers/dma/stm32-dmamux.c | 6 +++---
drivers/dma/stm32-mdma.c | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)

--
2.23.0


2020-11-27 09:46:01

by Qinglang Miao

[permalink] [raw]
Subject: [PATCH 1/3] dmaengine: stm32-dma: fix reference leak in stm32_dma

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 <[email protected]>
Signed-off-by: Qinglang Miao <[email protected]>
---
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