[PATCH] hwrng: stm32: fix usage_count leak when autosuspend_delay is negative

Daniel Thompson danielt at kernel.org
Mon Aug 10 03:24:41 PDT 2026


On Sat, Aug 08, 2026 at 03:45:10PM +0800, Guangshuo Li wrote:
> stm32_rng_probe() calls pm_runtime_use_autosuspend(), but neither the
> probe failure path nor stm32_rng_remove() calls the matching
> pm_runtime_dont_use_autosuspend() before disabling runtime PM.
>
> If the autosuspend delay is set to a negative value while autosuspend
> is enabled, the runtime PM core increments usage_count to prevent
> runtime suspend. Without calling pm_runtime_dont_use_autosuspend()
> during teardown, this reference is not dropped and usage_count remains
> unbalanced.

If calls to pm_runtime_use_autosuspend() must be paired with
pm_runtime_dont_use_autosuspend() then I wonder if having a
devm_pm_runtime_use_autosuspend() would be worthwhile?

That way stm32_rng_remove() could be entirely replaced with devres
cleanup.


Daniel.



More information about the linux-arm-kernel mailing list