mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Martin Kaiser <martin@kaiser.cx>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Hadar Gat <hadar.gat@arm.com>,
	Olivia Mackall <olivia@selenic.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-crypto@vger.kernel.org
Subject: Re: [PATCH] hwrng: cctrng - Fix an error handling path in cctrng_probe
Date: Tue, 27 Oct 2026 09:22:46 +0100	[thread overview]
Message-ID: <auBfVkwtsMUdgyG9@akranes.kaiser.cx> (raw)
In-Reply-To: <b66b3df3d178a04b35690d0eb36dee409a95aa5d.1792782868.git.christophe.jaillet@wanadoo.fr>

The sashiko review makes sense to me. We should probably call
pm_runtime_put_noidle after post_pm_err.

Best regards,
Martin

Thus wrote Christophe JAILLET (christophe.jaillet@wanadoo.fr):

> If an error occurs after a successful cc_trng_pm_init() call, it must be
> undone by a corresponding cc_trng_pm_fini() call.

> The commit in Fixes has erroneously updated the error handling path if
> cc_trng_pm_get() fails.

> Fixes: 8bcd96893848 ("hwrng: cctrng - let devres enable the clock")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only.

> This patch also undo the clean-up done by commit a7ea3d63e897 ("hwrng:
> cctrng - simplify cctrng_probe()"). Keeping an error path makes sense with
> 2 users. But if preferred, the missing cc_trng_pm_fini() could also be
> added after the test for errors in cc_trng_pm_get().
> ---
>  drivers/char/hw_random/cctrng.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)

> diff --git a/drivers/char/hw_random/cctrng.c b/drivers/char/hw_random/cctrng.c
> index 03401ee59a8e..608b3321c05a 100644
> --- a/drivers/char/hw_random/cctrng.c
> +++ b/drivers/char/hw_random/cctrng.c
> @@ -524,8 +524,10 @@ static int cctrng_probe(struct platform_device *pdev)

>  	/* increment device's usage counter */
>  	rc = cc_trng_pm_get(dev);
> -	if (rc)
> -		return dev_err_probe(dev, rc, "cc_trng_pm_get returned %x\n", rc);
> +	if (rc) {
> +		dev_err_probe(dev, rc, "cc_trng_pm_get returned %x\n", rc);
> +		goto post_pm_err;
> +	}

>  	/* set pending_hw to verify that HW won't be triggered from read */
>  	atomic_set(&drvdata->pending_hw, 1);
> @@ -534,8 +536,7 @@ static int cctrng_probe(struct platform_device *pdev)
>  	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;
> +		goto post_pm_err;
>  	}

>  	/* trigger HW to start generate data */
> @@ -548,6 +549,11 @@ static int cctrng_probe(struct platform_device *pdev)
>  	dev_info(dev, "ARM cctrng device initialized\n");

>  	return 0;
> +
> +post_pm_err:
> +	cc_trng_pm_fini(drvdata);
> +
> +	return rc;
>  }

>  static void cctrng_remove(struct platform_device *pdev)
> -- 
> 2.56.0


  reply	other threads:[~2026-10-27  8:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 19:14 Christophe JAILLET
2026-10-27  8:22 ` Martin Kaiser [this message]
2026-10-27 21:17   ` Christophe JAILLET

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=auBfVkwtsMUdgyG9@akranes.kaiser.cx \
    --to=martin@kaiser.cx \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=hadar.gat@arm.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olivia@selenic.com \
    /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

all inboxes | Powered by JetHome®