From: sashiko-bot@kernel.org
To: "Jiawen Liu" <1298662399@qq.com>,
"Olivia Mackall" <olivia@selenic.com>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
"Frank Li" <Frank.Li@nxp.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>
Cc: "Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
linux-crypto@vger.kernel.org, imx@lists.linux.dev,
Frank.Li@kernel.org
Subject: Re: [PATCH] hwrng: imx-rngc - fix runtime PM setup failure
Date: Sun, 29 Nov 2026 13:57:31 +0000 [thread overview]
Message-ID: <sashiko-outbox-239661@kernel.org> (raw)
In-Reply-To: <tencent_E83A64A52E8D1310A0E3AF63A564FD441106@qq.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] hwrng: imx-rngc: clock leak on devm_hwrng_register() error in
imx_rngc_probe()
--
commit a90c66e5122e753cea99f489c48d3ebf74c67153
Author: Jiawen Liu <1298662399@qq.com>
hwrng: imx-rngc - fix runtime PM setup failure
This commit checks the return value of devm_pm_runtime_enable() in
imx_rngc_probe() and holds a temporary runtime PM reference around the
setup and hwrng registration.
> diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
> index 8dfd7821225c1..948f3ef9e8d69 100644
> --- a/drivers/char/hw_random/imx-rngc.c
> +++ b/drivers/char/hw_random/imx-rngc.c
> @@ -312,13 +312,21 @@ static int __init imx_rngc_probe(struct platform_device *pdev)
> pm_runtime_set_autosuspend_delay(&pdev->dev, RNGC_PM_TIMEOUT);
> pm_runtime_use_autosuspend(&pdev->dev);
> pm_runtime_set_active(&pdev->dev);
> - devm_pm_runtime_enable(&pdev->dev);
> + pm_runtime_get_noresume(&pdev->dev);
> + ret = devm_pm_runtime_enable(&pdev->dev);
> + if (ret) {
> + pm_runtime_put_noidle(&pdev->dev);
> + clk_disable_unprepare(rngc->clk);
> + return dev_err_probe(&pdev->dev, ret,
> + "Failed to enable runtime PM\n");
> + }
>
> ret = devm_hwrng_register(&pdev->dev, &rngc->rng);
> if (ret) {
> - clk_disable_unprepare(rngc->clk);
> + pm_runtime_put(&pdev->dev);
> return dev_err_probe(&pdev->dev, ret, "hwrng registration failed\n");
> }
[Severity: Medium]
Does replacing clk_disable_unprepare(rngc->clk) with pm_runtime_put() leak
rngc->clk when devm_hwrng_register() fails?
imx_rngc_probe() enables rngc->clk manually with clk_prepare_enable() and
relies on imx_rngc_suspend() to disable it during devres teardown. When
CONFIG_PM is disabled, devm_pm_runtime_enable() and pm_runtime_put() are
no-ops and imx_rngc_driver.driver.pm is NULL via pm_ptr(), so
imx_rngc_suspend() never runs and rngc->clk stays prepared and enabled.
Even with CONFIG_PM enabled, pm_runtime_put() only schedules asynchronous
autosuspend. If the autosuspend timer fires and queues RPM_REQ_AUTOSUSPEND
before pm_runtime_disable_action() runs, rpm_idle() in
pm_runtime_dont_use_autosuspend() returns -EAGAIN and pm_runtime_disable()
cancels the pending work item without running imx_rngc_suspend().
--
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_E83A64A52E8D1310A0E3AF63A564FD441106@qq.com?part=1
prev parent reply other threads:[~2026-11-29 13:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 13:43 [PATCH] hwrng: imx-rngc - fix runtime PM setup failure Jiawen Liu
2026-11-29 13:57 ` sashiko-bot [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=sashiko-outbox-239661@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=1298662399@qq.com \
--cc=Frank.Li@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=festevam@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-crypto@vger.kernel.org \
--cc=olivia@selenic.com \
--cc=s.hauer@pengutronix.de \
--cc=sashiko-reviews@lists.linux.dev \
/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