diff mbox series

[-next] hwrng: exynos - fix PM reference leak in exynos_trng_probe()

Message ID 20210409061125.214255-1-yeweihua4@huawei.com (mailing list archive)
State Not Applicable
Headers show
Series [-next] hwrng: exynos - fix PM reference leak in exynos_trng_probe() | expand

Commit Message

Ye Weihua April 9, 2021, 6:11 a.m. UTC
pm_runtime_get_sync will increment pm usage counter even it failed.
Forgetting to putting operation will result in reference leak here.
Fix it by replacing it with pm_runtime_resume_and_get to keep usage
counter balanced.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Ye Weihua <yeweihua4@huawei.com>
---
 drivers/char/hw_random/exynos-trng.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Krzysztof Kozlowski April 9, 2021, 6:17 a.m. UTC | #1
On Fri, 9 Apr 2021 at 08:11, Ye Weihua <yeweihua4@huawei.com> wrote:
>
> pm_runtime_get_sync will increment pm usage counter even it failed.
> Forgetting to putting operation will result in reference leak here.
> Fix it by replacing it with pm_runtime_resume_and_get to keep usage
> counter balanced.
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Ye Weihua <yeweihua4@huawei.com>

Hi,

The same Lukasz' comment applies here as for Qinglang's patch from
November 2020 - resume also needs fix up.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
index 8e1fe3f8dd2d..666246bc8cca 100644
--- a/drivers/char/hw_random/exynos-trng.c
+++ b/drivers/char/hw_random/exynos-trng.c
@@ -132,7 +132,7 @@  static int exynos_trng_probe(struct platform_device *pdev)
 		return PTR_ERR(trng->mem);
 
 	pm_runtime_enable(&pdev->dev);
-	ret = pm_runtime_get_sync(&pdev->dev);
+	ret = pm_runtime_resume_and_get(&pdev->dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Could not get runtime PM.\n");
 		goto err_pm_get;