* [PATCH] hwrng: cctrng - Fix runtime PM usage counter leak
@ 2026-08-14 13:39 Ruoyu Wang
2026-09-04 10:01 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Ruoyu Wang @ 2026-08-14 13:39 UTC (permalink / raw)
To: Hadar Gat, Olivia Mackall, Herbert Xu
Cc: linux-crypto, linux-kernel, Ruoyu Wang
pm_runtime_get_sync() increments the device usage counter even when
runtime resume fails. cctrng_read() propagates errors from
cc_trng_pm_get() without scheduling the work that later drops the
counter, so a clock or reset-completion failure in cctrng_resume()
leaves the counter elevated.
Use pm_runtime_resume_and_get(), which drops the usage counter when
resume fails and returns zero on success. This preserves the existing
success path while balancing the error path.
This issue was found by a static analysis checker and confirmed by
manual source review.
Fixes: a583ed310bb6 ("hwrng: cctrng - introduce Arm CryptoCell driver")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
drivers/char/hw_random/cctrng.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/char/hw_random/cctrng.c b/drivers/char/hw_random/cctrng.c
index a5be9258037f8..41c338a768ce9 100644
--- a/drivers/char/hw_random/cctrng.c
+++ b/drivers/char/hw_random/cctrng.c
@@ -86,12 +86,7 @@ static inline u32 cc_ioread(struct cctrng_drvdata *drvdata, u32 reg)
static int cc_trng_pm_get(struct device *dev)
{
- int rc = 0;
-
- rc = pm_runtime_get_sync(dev);
-
- /* pm_runtime_get_sync() can return 1 as a valid return code */
- return (rc == 1 ? 0 : rc);
+ return pm_runtime_resume_and_get(dev);
}
static void cc_trng_pm_put_suspend(struct device *dev)
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] hwrng: cctrng - Fix runtime PM usage counter leak
2026-08-14 13:39 [PATCH] hwrng: cctrng - Fix runtime PM usage counter leak Ruoyu Wang
@ 2026-09-04 10:01 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2026-09-04 10:01 UTC (permalink / raw)
To: Ruoyu Wang; +Cc: Hadar Gat, Olivia Mackall, linux-crypto, linux-kernel
On Fri, Aug 14, 2026 at 09:39:33PM +0800, Ruoyu Wang wrote:
> pm_runtime_get_sync() increments the device usage counter even when
> runtime resume fails. cctrng_read() propagates errors from
> cc_trng_pm_get() without scheduling the work that later drops the
> counter, so a clock or reset-completion failure in cctrng_resume()
> leaves the counter elevated.
>
> Use pm_runtime_resume_and_get(), which drops the usage counter when
> resume fails and returns zero on success. This preserves the existing
> success path while balancing the error path.
>
> This issue was found by a static analysis checker and confirmed by
> manual source review.
>
> Fixes: a583ed310bb6 ("hwrng: cctrng - introduce Arm CryptoCell driver")
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
> ---
> drivers/char/hw_random/cctrng.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
Patch applied. Thanks.
--
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] 2+ messages in thread
end of thread, other threads:[~2026-09-04 10:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 13:39 [PATCH] hwrng: cctrng - Fix runtime PM usage counter leak Ruoyu Wang
2026-09-04 10:01 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox