* [PATCH v1] hwrng: ks-sa: Fix runtime PM cleanup on registration failure
@ 2026-07-02 23:39 Yuho Choi
2026-07-13 3:44 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-07-02 23:39 UTC (permalink / raw)
To: Olivia Mackall, Herbert Xu
Cc: Alexander Sverdlin, Nishanth Menon, linux-crypto, linux-kernel,
Yuho Choi
ks_sa_rng_probe() enables runtime PM and resumes the device before
registering the hwrng. If devm_hwrng_register() fails, probe returns
without dropping the runtime PM usage count or disabling runtime PM.
Unwind the runtime PM state on the registration failure path, matching
the cleanup done by remove().
Fixes: e9009fb227fa ("hwrng: ks-sa - Use pm_runtime_resume_and_get() to replace open coding")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
drivers/char/hw_random/ks-sa-rng.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/char/hw_random/ks-sa-rng.c b/drivers/char/hw_random/ks-sa-rng.c
index 9e408144a10c..4494f1e4ab4d 100644
--- a/drivers/char/hw_random/ks-sa-rng.c
+++ b/drivers/char/hw_random/ks-sa-rng.c
@@ -242,7 +242,14 @@ static int ks_sa_rng_probe(struct platform_device *pdev)
return dev_err_probe(dev, ret, "Failed to enable SA power-domain\n");
}
- return devm_hwrng_register(&pdev->dev, &ks_sa_rng->rng);
+ ret = devm_hwrng_register(dev, &ks_sa_rng->rng);
+ if (ret) {
+ pm_runtime_put_sync(dev);
+ pm_runtime_disable(dev);
+ return ret;
+ }
+
+ return 0;
}
static void ks_sa_rng_remove(struct platform_device *pdev)
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v1] hwrng: ks-sa: Fix runtime PM cleanup on registration failure
2026-07-02 23:39 [PATCH v1] hwrng: ks-sa: Fix runtime PM cleanup on registration failure Yuho Choi
@ 2026-07-13 3:44 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2026-07-13 3:44 UTC (permalink / raw)
To: Yuho Choi
Cc: Olivia Mackall, Alexander Sverdlin, Nishanth Menon, linux-crypto,
linux-kernel
On Thu, Jul 02, 2026 at 07:39:21PM -0400, Yuho Choi wrote:
> ks_sa_rng_probe() enables runtime PM and resumes the device before
> registering the hwrng. If devm_hwrng_register() fails, probe returns
> without dropping the runtime PM usage count or disabling runtime PM.
>
> Unwind the runtime PM state on the registration failure path, matching
> the cleanup done by remove().
>
> Fixes: e9009fb227fa ("hwrng: ks-sa - Use pm_runtime_resume_and_get() to replace open coding")
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> ---
> drivers/char/hw_random/ks-sa-rng.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
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-07-13 3:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-02 23:39 [PATCH v1] hwrng: ks-sa: Fix runtime PM cleanup on registration failure Yuho Choi
2026-07-13 3:44 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox