Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Martin Kaiser <lists@kaiser.cx>
To: Ma Yukun <0x4fe6@gmail.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>, linux-crypto@vger.kernel.org
Subject: Re: [PATCH v2] hwrng: imx-rngc - check return value of clk_prepare_enable()
Date: Fri, 11 Sep 2026 09:12:29 +0200	[thread overview]
Message-ID: <aqOp3R0imhec2HnT@akranes.kaiser.cx> (raw)
In-Reply-To: <178869518976.1724.8613243679737914482@gmail.com>

Thus wrote Ma Yukun (0x4fe6@gmail.com):

> 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

This has already been fixed.

https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git/commit/?id=8ba2b068e1b3607289ba5778e4c27c167fdbfee6

      reply	other threads:[~2026-09-11  7:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aqOp3R0imhec2HnT@akranes.kaiser.cx \
    --to=lists@kaiser.cx \
    --cc=0x4fe6@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox