Re: [PATCH] hwrng: jh7110: fix refcount leak in starfive_trng_read()

From: Herbert Xu

Date: Thu Jun 11 2026 - 04:54:57 EST


On Wed, Jun 03, 2026 at 11:03:27AM +0000, Wentao Liang wrote:
> The starfive_trng_read() function acquires a runtime PM reference
> via pm_runtime_get_sync() but fails to release it on two error
> paths. If starfive_trng_wait_idle() or starfive_trng_cmd() returns
> an error, the function exits without calling
> pm_runtime_put_sync_autosuspend(), leaving the runtime PM usage
> counter permanently elevated and preventing the device from entering
> runtime suspend.
>
> Refactor the function to use a unified error path that calls
> pm_runtime_put_sync_autosuspend() before returning.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: c388f458bc34 ("hwrng: starfive - Add TRNG driver for StarFive SoC")
> Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
> ---
> drivers/char/hw_random/jh7110-trng.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)

Patch applied. Thanks.
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt