Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH v2] hwrng: imx-rngc - check return value of clk_prepare_enable()
@ 2026-09-06 11:46 Ma Yukun
  2026-09-11  7:12 ` Martin Kaiser
  0 siblings, 1 reply; 2+ messages in thread
From: Ma Yukun @ 2026-09-06 11:46 UTC (permalink / raw)
  To: Herbert Xu; +Cc: Martin Kaiser, linux-crypto

clk_prepare_enable() can fail here and its return value is currently
ignored. If the clock fails to enable, the probe continues to read
from the hardware registers without a clock, which can cause a bus
hang or external abort.

Check the return value and fail probe if the clock cannot be enabled.

Fixes: 1d5449445bd0 ("hwrng: mx-rngc - add a driver for Freescale RNGC")
Signed-off-by: Ma Yukun <0x4fe6@gmail.com>
---
v2: fix patch formatting, add missing context line

 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 7693328f1..58bdc7a6b 100644
--- a/drivers/char/hw_random/imx-rngc.c
+++ b/drivers/char/hw_random/imx-rngc.c
@@ -266,7 +266,9 @@ static int __init imx_rngc_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	clk_prepare_enable(rngc->clk);
+	ret = clk_prepare_enable(rngc->clk);
+	if (ret)
+		return ret;
 
 	ver_id = readl(rngc->base + RNGC_VER_ID);
 	rng_type = FIELD_GET(RNG_TYPE, ver_id);
-- 
2.43.0

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

end of thread, other threads:[~2026-09-11  7:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-06 11:46 [PATCH v2] hwrng: imx-rngc - check return value of clk_prepare_enable() Ma Yukun
2026-09-11  7:12 ` Martin Kaiser

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