* [PATCH] char: hw_random: Fix a reference count leak.
@ 2020-06-13 21:41 wu000273
2020-06-15 6:58 ` Krzysztof Kozlowski
[not found] ` <CGME20200615131915eucas1p2b8f3fa0ceb757e36aa888a4476de034f@eucas1p2.samsung.com>
0 siblings, 2 replies; 4+ messages in thread
From: wu000273 @ 2020-06-13 21:41 UTC (permalink / raw)
To: kjlu
Cc: wu000273, Łukasz Stelmach, Matt Mackall, Herbert Xu,
Arnd Bergmann, Greg Kroah-Hartman, Kukjin Kim,
Krzysztof Kozlowski, Philippe Ombredanne, linux-samsung-soc,
linux-crypto, linux-arm-kernel, linux-kernel
From: Qiushi Wu <wu000273@umn.edu>
Calling pm_runtime_get_sync increments the counter even in case of
failure, causing incorrect ref count if pm_runtime_put_sync is not
called in error handling paths. Thus replace the jump target
"err_pm_get" by "err_clock".
Fixes: 6cd225cc5d8a ("hwrng: exynos - add Samsung Exynos True RNG driver")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
drivers/char/hw_random/exynos-trng.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
index 8e1fe3f8dd2d..ffa7e0f061f0 100644
--- a/drivers/char/hw_random/exynos-trng.c
+++ b/drivers/char/hw_random/exynos-trng.c
@@ -135,7 +135,7 @@ static int exynos_trng_probe(struct platform_device *pdev)
ret = pm_runtime_get_sync(&pdev->dev);
if (ret < 0) {
dev_err(&pdev->dev, "Could not get runtime PM.\n");
- goto err_pm_get;
+ goto err_clock;
}
trng->clk = devm_clk_get(&pdev->dev, "secss");
@@ -166,8 +166,6 @@ static int exynos_trng_probe(struct platform_device *pdev)
err_clock:
pm_runtime_put_sync(&pdev->dev);
-
-err_pm_get:
pm_runtime_disable(&pdev->dev);
return ret;
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] char: hw_random: Fix a reference count leak.
2020-06-13 21:41 [PATCH] char: hw_random: Fix a reference count leak wu000273
@ 2020-06-15 6:58 ` Krzysztof Kozlowski
[not found] ` <CGME20200615131915eucas1p2b8f3fa0ceb757e36aa888a4476de034f@eucas1p2.samsung.com>
1 sibling, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2020-06-15 6:58 UTC (permalink / raw)
To: wu000273
Cc: kjlu, Łukasz Stelmach, Matt Mackall, Herbert Xu,
Arnd Bergmann, Greg Kroah-Hartman, Kukjin Kim,
Philippe Ombredanne, linux-samsung-soc, linux-crypto,
linux-arm-kernel, linux-kernel
On Sat, Jun 13, 2020 at 04:41:28PM -0500, wu000273@umn.edu wrote:
> From: Qiushi Wu <wu000273@umn.edu>
>
> Calling pm_runtime_get_sync increments the counter even in case of
> failure, causing incorrect ref count if pm_runtime_put_sync is not
> called in error handling paths. Thus replace the jump target
> "err_pm_get" by "err_clock".
>
> Fixes: 6cd225cc5d8a ("hwrng: exynos - add Samsung Exynos True RNG driver")
> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
1. Cc: <stable@vger.kernel.org>
2. Subject prefix:
hwrng: exynos -
3. Subject title: Fix PM runtime reference count leak
(no need for end stop)
With these changes:
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] char: hw_random: Fix a reference count leak.
[not found] ` <CGME20200615131915eucas1p2b8f3fa0ceb757e36aa888a4476de034f@eucas1p2.samsung.com>
@ 2020-06-15 13:18 ` Lukasz Stelmach
2020-06-16 7:31 ` Herbert Xu
0 siblings, 1 reply; 4+ messages in thread
From: Lukasz Stelmach @ 2020-06-15 13:18 UTC (permalink / raw)
To: wu000273, Herbert Xu
Cc: kjlu, Matt Mackall, Arnd Bergmann, Greg Kroah-Hartman,
Kukjin Kim, Krzysztof Kozlowski, Philippe Ombredanne,
linux-samsung-soc, linux-crypto, linux-arm-kernel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1692 bytes --]
It was <2020-06-13 sob 16:41>, when wu000273@umn.edu wrote:
> From: Qiushi Wu <wu000273@umn.edu>
>
> Calling pm_runtime_get_sync increments the counter even in case of
> failure, causing incorrect ref count if pm_runtime_put_sync is not
> called in error handling paths. Thus replace the jump target
> "err_pm_get" by "err_clock".
>
> Fixes: 6cd225cc5d8a ("hwrng: exynos - add Samsung Exynos True RNG driver")
> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
> ---
> drivers/char/hw_random/exynos-trng.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
> index 8e1fe3f8dd2d..ffa7e0f061f0 100644
> --- a/drivers/char/hw_random/exynos-trng.c
> +++ b/drivers/char/hw_random/exynos-trng.c
> @@ -135,7 +135,7 @@ static int exynos_trng_probe(struct platform_device *pdev)
> ret = pm_runtime_get_sync(&pdev->dev);
> if (ret < 0) {
> dev_err(&pdev->dev, "Could not get runtime PM.\n");
> - goto err_pm_get;
> + goto err_clock;
> }
>
> trng->clk = devm_clk_get(&pdev->dev, "secss");
> @@ -166,8 +166,6 @@ static int exynos_trng_probe(struct platform_device *pdev)
>
> err_clock:
> pm_runtime_put_sync(&pdev->dev);
> -
> -err_pm_get:
> pm_runtime_disable(&pdev->dev);
>
> return ret;
I believe this fix has already been submitted
https://lore.kernel.org/linux-arm-kernel/20200522011659.26727-1-dinghao.liu@zju.edu.cn/T/#u
It hasn't been applied though. Anyway, thank you for your work.
Herbert, could you take a look at the Dinghao's patch, please?
--
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] char: hw_random: Fix a reference count leak.
2020-06-15 13:18 ` Lukasz Stelmach
@ 2020-06-16 7:31 ` Herbert Xu
0 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2020-06-16 7:31 UTC (permalink / raw)
To: Lukasz Stelmach
Cc: wu000273, kjlu, Matt Mackall, Arnd Bergmann, Greg Kroah-Hartman,
Kukjin Kim, Krzysztof Kozlowski, Philippe Ombredanne,
linux-samsung-soc, linux-crypto, linux-arm-kernel, linux-kernel
On Mon, Jun 15, 2020 at 03:18:54PM +0200, Lukasz Stelmach wrote:
>
> I believe this fix has already been submitted
>
> https://lore.kernel.org/linux-arm-kernel/20200522011659.26727-1-dinghao.liu@zju.edu.cn/T/#u
>
> It hasn't been applied though. Anyway, thank you for your work.
>
> Herbert, could you take a look at the Dinghao's patch, please?
It was part of a number of patches that did similar things. The
general conclusion was that it should call put_noidle instead.
See
https://patchwork.kernel.org/patch/11574843/
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-16 7:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-13 21:41 [PATCH] char: hw_random: Fix a reference count leak wu000273
2020-06-15 6:58 ` Krzysztof Kozlowski
[not found] ` <CGME20200615131915eucas1p2b8f3fa0ceb757e36aa888a4476de034f@eucas1p2.samsung.com>
2020-06-15 13:18 ` Lukasz Stelmach
2020-06-16 7:31 ` Herbert Xu
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).