Re: [PATCH 3/4] hwrng: starfive - Fix runtime PM leak in starfive_trng_read()
From: Herbert Xu
Date: Wed Sep 23 2026 - 01:15:36 EST
On Tue, Sep 15, 2026 at 03:54:48AM +0000, Wentao Liang wrote:
> starfive_trng_read() takes a runtime PM reference with
> pm_runtime_get_sync(trng->dev), which leaves the device's usage
> count incremented even when it fails, and balances it with
> pm_runtime_put_sync_autosuspend() on the success path only. If
> starfive_trng_wait_idle() times out or starfive_trng_cmd() fails,
> the function returns early without dropping the reference, leaking
> it on every failed read.
>
> Convert the pm_runtime_get_sync() call to
> pm_runtime_resume_and_get(), which drops the reference again on
> failure, and release the reference with
> pm_runtime_put_sync_autosuspend() before the two early returns.
>
> Fixes: c388f458bc34 ("hwrng: starfive - Add TRNG driver for StarFive SoC")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
> ---
> drivers/char/hw_random/jh7110-trng.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
Your patch series is incomplete and cannot be reviewed:
https://sashiko.dev/#/patchset/74190
Cheers,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt