From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Martin Kaiser <martin@kaiser.cx>
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 22:17:07 +0100 [thread overview]
Message-ID: <67844d9d-d4d4-4026-9549-73589afcc1ff@wanadoo.fr> (raw)
In-Reply-To: <auBfVkwtsMUdgyG9@akranes.kaiser.cx>
Le 27/10/2026 à 09:22, Martin Kaiser a écrit :
> The sashiko review makes sense to me. We should probably call
> pm_runtime_put_noidle after post_pm_err.
>
> Best regards,
> Martin
>
I agree that my patch looks broken.
I've not followed all sashiko explanation, but usually I try to stay
away from pm code, which most of the time looks too tricky for me.
So should something be fixed here, I'll leave it to you.
CJ
> 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
>
prev parent reply other threads:[~2026-10-27 21:17 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
2026-10-27 21:17 ` Christophe JAILLET [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=67844d9d-d4d4-4026-9549-73589afcc1ff@wanadoo.fr \
--to=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=martin@kaiser.cx \
--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®