Re: [PATCH] iio: proximity: srf04: fix runtime PM autosuspend cleanup

Jonathan Cameron <[email protected]>
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <20260822010809.04404b4e@jic23-huawei>
On Tue, 18 Aug 2026 09:14:15 +0200
Johan Hovold <[email protected]> wrote:

> On Fri, Aug 07, 2026 at 10:19:37PM +0800, Guangshuo Li wrote:
> > srf04_probe() calls pm_runtime_use_autosuspend() when the optional
> > power GPIO is present, but srf04_remove() does not call the matching
> > pm_runtime_dont_use_autosuspend() before disabling runtime PM.
> > 
> > The runtime PM documentation requires pm_runtime_use_autosuspend() to
> > be balanced with pm_runtime_dont_use_autosuspend() when the driver is
> > removed. Failing to do so can leave the autosuspend usage state
> > unbalanced and may result in a usage_count leak when the autosuspend
> > delay is negative.  
> 
> I believe the term "leak" here is misleading as the usage count would be
> dropped again when the user re-enables autosuspend through sysfs, right?

A user has no reason to do that under normal circumstances.
So whilst that might work it is rather non user friendly to the extent
I think I'd consider it a bug that should be fixed.  Backport or not
is a different question.

Jonathan


> 
> That said, drivers should clean up after themselves so disabling
> autosuspend is still the right to do. But it's more of a cleanup than a
> fix (and does not need to be backported).
> 
> Johan
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.