Re: [PATCH 1/6] usb: core: add missing pm_runtime_dont_use_autosuspend() call

From: Johan Hovold

Date: Wed Sep 16 2026 - 05:23:23 EST


On Wed, Sep 16, 2026 at 10:21:32AM +0200, Joshua Crofts wrote:
> On Wed, 16 Sep 2026 10:08:52 +0200
> Johan Hovold <johan@xxxxxxxxxx> wrote:
>
> > On Tue, Sep 15, 2026 at 09:02:18AM +0000, Joshua Crofts wrote:
> > > The fail label in usb_new_device() disables pm_runtime on failure, but
> > > doesn't call pm_runtime_dont_use_autosuspend(), causing resource leaks.
> >
> > No it does not, as the device itself is about to be freed. Sure we could
> > disable autosuspend again here, but it does not really matter.
> >
>
> Okay, commit message aside, you still need to call dont_use_autosuspend()
> on teardown as the driver doesn't use the devm_* counterparts.

No, you don't *need* to call it, but it is good practice to clean up
after yourself even for the theoretical corner case of someone forcibly
rebinding a different driver (which will soon also be tainting the
kernel).

But in this particular case (usb core) where all callers *free* the
device after the function returns it does not matter one bit.

> Currently
> (according to my cocci SmPL [1]) there are 195 instances of this in the kernel.
>
> ...
>
> > But this one should not have a Fixes tag and does not need to be
> > backported.
>
> Yeah, you already mentioned this in IIO once [2]. I found several instances
> of patches like these being backported however, so perhaps times have changed.

If you write a misleading commit message and add a CC stable tag,
chances are that a maintainer will miss this when reviewing and then
the commit gets backported.

That in no way means that you should continue doing so on purpose,
that's bordering willful deception.

Johan

> [1] https://lore.kernel.org/cocci/20260915064327.1377-1-joshua.crofts1@xxxxxxxxx/
> [2] https://lore.kernel.org/linux-iio/aoQEyeHUiTwWenBL@xxxxxxxxxxxxxxxxxxxx/