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

From: Johan Hovold

Date: Wed Sep 16 2026 - 04:20:35 EST


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.

You could consider balancing the runtime pm count as well, as I guess
both of these could trip up static checkers (cf. [1]).

> Add the missing pm_runtime_dont_use_autosuspend() call.
>
> Found using Coccinelle.
>
> Fixes: fcc4a01eb866 ("USB: use the runtime-PM autosuspend implementation")
> Cc: <stable@xxxxxxxxxxxxxxx>

But this one should not have a Fixes tag and does not need to be
backported.

> Signed-off-by: Joshua Crofts <joshua.crofts1@xxxxxxxxx>
> ---
> drivers/usb/core/hub.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 3345b3298daf..dec6d5c49759 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -2745,6 +2745,7 @@ int usb_new_device(struct usb_device *udev)
> fail:
> usb_set_device_state(udev, USB_STATE_NOTATTACHED);
> pm_runtime_disable(&udev->dev);
> + pm_runtime_dont_use_autosuspend(&udev->dev);
> pm_runtime_set_suspended(&udev->dev);
> return err;
> }

Johan

[1] https://lore.kernel.org/all/aivMnTkZ-jTRH2Jy@xxxxxxxxxxxxxxxxxxxx/