linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] crypto: stm32 - fix reference leak
@ 2020-11-27  9:46 Qinglang Miao
  2020-11-27  9:46 ` [PATCH 1/2] crypto: stm32/cryp - fix reference leak in stm32_cryp_remove Qinglang Miao
  2020-11-27  9:46 ` [PATCH 2/2] crypto: stm32/hash - fix reference leak in stm32_hash_remove Qinglang Miao
  0 siblings, 2 replies; 3+ messages in thread
From: Qinglang Miao @ 2020-11-27  9:46 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Maxime Coquelin, Alexandre Torgue
  Cc: linux-crypto, 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. 

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] crypto: stm32/cryp - fix reference leak in stm32_cryp_remove
  2020-11-27  9:46 [PATCH 0/2] crypto: stm32 - fix reference leak Qinglang Miao
@ 2020-11-27  9:46 ` Qinglang Miao
  2020-11-27  9:46 ` [PATCH 2/2] crypto: stm32/hash - fix reference leak in stm32_hash_remove Qinglang Miao
  1 sibling, 0 replies; 3+ messages in thread
From: Qinglang Miao @ 2020-11-27  9:46 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Maxime Coquelin, Alexandre Torgue
  Cc: linux-crypto, 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: 65f9aa36ee47 ("crypto: stm32/cryp - Add power management support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
 drivers/crypto/stm32/stm32-cryp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/stm32/stm32-cryp.c b/drivers/crypto/stm32/stm32-cryp.c
index 2670c3033..7f3b84973 100644
--- a/drivers/crypto/stm32/stm32-cryp.c
+++ b/drivers/crypto/stm32/stm32-cryp.c
@@ -2043,7 +2043,7 @@ static int stm32_cryp_remove(struct platform_device *pdev)
 	if (!cryp)
 		return -ENODEV;
 
-	ret = pm_runtime_get_sync(cryp->dev);
+	ret = pm_runtime_resume_and_get(cryp->dev);
 	if (ret < 0)
 		return ret;
 
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] crypto: stm32/hash - fix reference leak in stm32_hash_remove
  2020-11-27  9:46 [PATCH 0/2] crypto: stm32 - fix reference leak Qinglang Miao
  2020-11-27  9:46 ` [PATCH 1/2] crypto: stm32/cryp - fix reference leak in stm32_cryp_remove Qinglang Miao
@ 2020-11-27  9:46 ` Qinglang Miao
  1 sibling, 0 replies; 3+ messages in thread
From: Qinglang Miao @ 2020-11-27  9:46 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Maxime Coquelin, Alexandre Torgue
  Cc: linux-crypto, 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: 8b4d566de6a5 ("crypto: stm32/hash - Add power management support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-27  9:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-27  9:46 [PATCH 0/2] crypto: stm32 - fix reference leak Qinglang Miao
2020-11-27  9:46 ` [PATCH 1/2] crypto: stm32/cryp - fix reference leak in stm32_cryp_remove Qinglang Miao
2020-11-27  9:46 ` [PATCH 2/2] crypto: stm32/hash - fix reference leak in stm32_hash_remove Qinglang Miao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).