Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH v1] hwrng: imx-rngc: Disable clock on registration failure
@ 2026-08-02 22:22 Yuho Choi
  2026-08-07  7:25 ` Martin Kaiser
  0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-08-02 22:22 UTC (permalink / raw)
  To: olivia, herbert, Frank.Li, s.hauer
  Cc: kernel, festevam, linux-crypto, imx, linux-arm-kernel,
	linux-kernel, dakr, o-takashi, bhelgaas, Yuho Choi

The RNGC clock is enabled manually before runtime PM is configured. If
devm_hwrng_register() fails, probe returns without disabling the clock.
The devm_pm_runtime_enable() cleanup only disables runtime PM and does not
call imx_rngc_suspend().

Disable the clock before returning from this failure path.

Fixes: 7a96a64e8689 ("hwrng: imx-rngc - add runtime pm")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
 drivers/char/hw_random/imx-rngc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
index 28c56c2d1bf6..a2db26d7f790 100644
--- a/drivers/char/hw_random/imx-rngc.c
+++ b/drivers/char/hw_random/imx-rngc.c
@@ -313,8 +313,10 @@ static int __init imx_rngc_probe(struct platform_device *pdev)
 	devm_pm_runtime_enable(&pdev->dev);
 
 	ret = devm_hwrng_register(&pdev->dev, &rngc->rng);
-	if (ret)
+	if (ret) {
+		clk_disable_unprepare(rngc->clk);
 		return dev_err_probe(&pdev->dev, ret, "hwrng registration failed\n");
+	}
 
 	dev_info(&pdev->dev,
 		"Freescale RNG%c registered (HW revision %d.%02d)\n",
-- 
2.43.0


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

* Re: [PATCH v1] hwrng: imx-rngc: Disable clock on registration failure
  2026-08-02 22:22 [PATCH v1] hwrng: imx-rngc: Disable clock on registration failure Yuho Choi
@ 2026-08-07  7:25 ` Martin Kaiser
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Kaiser @ 2026-08-07  7:25 UTC (permalink / raw)
  To: Yuho Choi
  Cc: olivia, herbert, Frank.Li, s.hauer, kernel, festevam,
	linux-crypto, imx, linux-arm-kernel, linux-kernel, dakr,
	o-takashi, bhelgaas

Thus wrote Yuho Choi (dbgh9129@gmail.com):

> The RNGC clock is enabled manually before runtime PM is configured. If
> devm_hwrng_register() fails, probe returns without disabling the clock.
> The devm_pm_runtime_enable() cleanup only disables runtime PM and does not
> call imx_rngc_suspend().

> Disable the clock before returning from this failure path.

> Fixes: 7a96a64e8689 ("hwrng: imx-rngc - add runtime pm")
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> ---
>  drivers/char/hw_random/imx-rngc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

> diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
> index 28c56c2d1bf6..a2db26d7f790 100644
> --- a/drivers/char/hw_random/imx-rngc.c
> +++ b/drivers/char/hw_random/imx-rngc.c
> @@ -313,8 +313,10 @@ static int __init imx_rngc_probe(struct platform_device *pdev)
>  	devm_pm_runtime_enable(&pdev->dev);

>  	ret = devm_hwrng_register(&pdev->dev, &rngc->rng);
> -	if (ret)
> +	if (ret) {
> +		clk_disable_unprepare(rngc->clk);
>  		return dev_err_probe(&pdev->dev, ret, "hwrng registration failed\n");
> +	}

>  	dev_info(&pdev->dev,
>  		"Freescale RNG%c registered (HW revision %d.%02d)\n",
> -- 
> 2.43.0

Good catch, thanks.

Reviewed-by: Martin Kaiser <martin@kaiser.cx>

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

end of thread, other threads:[~2026-08-07  7:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-02 22:22 [PATCH v1] hwrng: imx-rngc: Disable clock on registration failure Yuho Choi
2026-08-07  7:25 ` Martin Kaiser

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