Skip to contentSkip to conversation

hwrng: cctrng - fix usage counter in error path

PATCH Superseded Martin Kaiser 2 participants 2 messages Oct 29

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwrng: cctrng - fix usage counter in error path

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")

---
based on sashiko review
https://lore.kernel.org/linux-crypto/[email protected]/T/#m1a770f5f9eeed95b48cad7545580aed4fa74e6fa

compile-tested only

 drivers/char/hw_random/cctrng.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/char/hw_random/cctrng.c +3 -3
index 03401ee59a8e..d9492d25ecbb 100644
@@ -533,9 +533,9 @@ 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: %d\n", rc);
 	}
 
 	/* trigger HW to start generate data */
Signature · 1 line
2.43.7
#1 lore raw

Le 29/10/2026 à 09:15, Martin Kaiser a écrit :

Quoted 22 lines

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")

---
based on sashiko review
https://lore.kernel.org/linux-crypto/[email protected]/T/#m1a770f5f9eeed95b48cad7545580aed4fa74e6fa

compile-tested only

  drivers/char/hw_random/cctrng.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/char/hw_random/cctrng.c +0 -0
index 03401ee59a8e..d9492d25ecbb 100644

drivers/char/hw_random/cctrng.c static int cctrng_probe(struct platform_device *pdev) · line 538

Quoted 9 lines
drivers/char/hw_random/cctrng.c +3 -3
@@ -533,9 +533,9 @@ 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: %d\n", rc);

No need to duplicate rc in a dev_err_probe() call.

CJ

Quoted 3 lines
drivers/char/hw_random/cctrng.c +0 -0
  	}
 
  	/* trigger HW to start generate data */