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

Daniel Thompson <[email protected]>
Newsgroups org.kernel.vger.linux-crypto,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <[email protected]>
On Tue, Aug 11, 2026 at 02:34:42PM +0800, Guangshuo Li wrote:
> stm32_rng_probe() calls pm_runtime_use_autosuspend(), but runtime PM is
> enabled with pm_runtime_enable() and the matching
> pm_runtime_dont_use_autosuspend() is not called on driver teardown.
>
> 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.
>
> Use devm_pm_runtime_enable() so that pm_runtime_dont_use_autosuspend()
> and pm_runtime_disable() are automatically called on probe failure and
> driver teardown. With runtime PM cleanup handled by devres,
> stm32_rng_remove() is no longer needed.
>
> This issue was found by manual code inspection.
>
> Fixes: c6a97c42e399 ("hwrng: stm32 - add support for STM32 HW RNG")
> Cc: [email protected]
> Signed-off-by: Guangshuo Li <[email protected]>
> ---
> v2:
>   - Replace pm_runtime_enable() with devm_pm_runtime_enable() to handle
>     runtime PM cleanup through devres.
>   - Remove stm32_rng_remove() and the manual cleanup on the probe failure
>     path.

devres changes look great!

Reviewed-by: Daniel Thompson (RISCstar) <[email protected]>


Daniel.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.