2020-11-27 09:45:41

by Qinglang Miao

[permalink] [raw]
Subject: [PATCH 0/2] crypto: 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 (2):
crypto: stm32/cryp - fix reference leak in stm32_cryp_remove
crypto: stm32/hash - fix reference leak in stm32_hash_remove

drivers/crypto/stm32/stm32-cryp.c | 2 +-
drivers/crypto/stm32/stm32-hash.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

--
2.23.0


2020-11-27 09:45:42

by Qinglang Miao

[permalink] [raw]
Subject: [PATCH 2/2] crypto: stm32/hash - fix reference leak in stm32_hash_remove

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: 8b4d566de6a5 ("crypto: stm32/hash - Add power management support")
Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Qinglang Miao <[email protected]>
---
drivers/crypto/stm32/stm32-hash.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c
index e3e25278a..16bb52836 100644
--- a/drivers/crypto/stm32/stm32-hash.c
+++ b/drivers/crypto/stm32/stm32-hash.c
@@ -1565,7 +1565,7 @@ static int stm32_hash_remove(struct platform_device *pdev)
if (!hdev)
return -ENODEV;

- ret = pm_runtime_get_sync(hdev->dev);
+ ret = pm_runtime_resume_and_get(hdev->dev);
if (ret < 0)
return ret;

--
2.23.0