mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] hwrng: cctrng - fix usage counter in error path
@ 2026-10-31 14:46 Martin Kaiser
  2026-11-12 10:16 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Kaiser @ 2026-10-31 14:46 UTC (permalink / raw)
  To: Hadar Gat, Olivia Mackall, Herbert Xu
  Cc: Christophe JAILLET, Martin Kaiser, linux-crypto, linux-kernel

If probe fails after the runtime pm usage counter was incremented,
we have to decrement it before we exit.

Remove the cc_trng_pm_fini call in the error path. It calls
pm_runtime_disable before runtime pm is enabled.

Fixes: a583ed310bb6 ("hwrng: cctrng - introduce Arm CryptoCell driver")
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
based on sashiko review
https://lore.kernel.org/linux-crypto/67844d9d-d4d4-4026-9549-73589afcc1ff@wanadoo.fr/T/#m1a770f5f9eeed95b48cad7545580aed4fa74e6fa

compile-tested only

v2:
 - don't duplicate the error code in dev_err_probe

 drivers/char/hw_random/cctrng.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/char/hw_random/cctrng.c b/drivers/char/hw_random/cctrng.c
index 03401ee59a8e..088aa031bf22 100644
--- a/drivers/char/hw_random/cctrng.c
+++ b/drivers/char/hw_random/cctrng.c
@@ -533,9 +533,8 @@ static int cctrng_probe(struct platform_device *pdev)
 	/* registration of the hwrng device */
 	rc = devm_hwrng_register(dev, &drvdata->rng);
 	if (rc) {
-		dev_err(dev, "Could not register hwrng device.\n");
-		cc_trng_pm_fini(drvdata);
-		return rc;
+		pm_runtime_put_noidle(dev);
+		return dev_err_probe(dev, rc, "Could not register hwrng device\n");
 	}
 
 	/* trigger HW to start generate data */
-- 
2.43.7


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

* Re: [PATCH v2] hwrng: cctrng - fix usage counter in error path
  2026-10-31 14:46 [PATCH v2] hwrng: cctrng - fix usage counter in error path Martin Kaiser
@ 2026-11-12 10:16 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2026-11-12 10:16 UTC (permalink / raw)
  To: Martin Kaiser
  Cc: Hadar Gat, Olivia Mackall, Christophe JAILLET, linux-crypto,
	linux-kernel

On Sat, Oct 31, 2026 at 03:46:20PM +0100, Martin Kaiser wrote:
> If probe fails after the runtime pm usage counter was incremented,
> we have to decrement it before we exit.
> 
> Remove the cc_trng_pm_fini call in the error path. It calls
> pm_runtime_disable before runtime pm is enabled.
> 
> Fixes: a583ed310bb6 ("hwrng: cctrng - introduce Arm CryptoCell driver")
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
> based on sashiko review
> https://lore.kernel.org/linux-crypto/67844d9d-d4d4-4026-9549-73589afcc1ff@wanadoo.fr/T/#m1a770f5f9eeed95b48cad7545580aed4fa74e6fa
> 
> compile-tested only
> 
> v2:
>  - don't duplicate the error code in dev_err_probe
> 
>  drivers/char/hw_random/cctrng.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 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-11-12 10:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-31 14:46 [PATCH v2] hwrng: cctrng - fix usage counter in error path Martin Kaiser
2026-11-12 10:16 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®