Re: [PATCH] usb: hcd-pci: avoid double disable on surprise removal

From: Alan Stern

Date: Tue Oct 20 2026 - 15:54:31 EST


On Tue, Oct 20, 2026 at 05:05:39PM +0200, Konrad Dybcio wrote:
> A PCI HCD can be surprise-removed after suspend_common() disables it
> and before resume_common() re-enables it. Avoid a second call to
> pci_disable_device() in the remove path when no enable reference
> remains.

Does the double disable actually cause any problems?

Alan Stern

> Signed-off-by: Konrad Dybcio <konrad.dybcio@xxxxxxxxxxxxxxxx>
> ---
> drivers/usb/core/hcd-pci.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
> index cd223475917ef199511311eda5c6aaef073b0ad4..34c4d352b40c40c54cf17c30fc264833ba05bcd6 100644
> --- a/drivers/usb/core/hcd-pci.c
> +++ b/drivers/usb/core/hcd-pci.c
> @@ -348,7 +348,9 @@ void usb_hcd_pci_remove(struct pci_dev *dev)
> usb_put_hcd(hcd);
> if ((hcd_driver_flags & HCD_MASK) < HCD_USB3)
> pci_free_irq_vectors(dev);
> - pci_disable_device(dev);
> +
> + if (pci_is_enabled(dev))
> + pci_disable_device(dev);
> }
> EXPORT_SYMBOL_GPL(usb_hcd_pci_remove);
>
>
> ---
> base-commit: f5f84daefcd92d7a630066635ecea1433ed5eac7
> change-id: 20261020-topic-hub_pci-903b8c18d17b
>
> Best regards,
> --
> Konrad Dybcio <konrad.dybcio@xxxxxxxxxxxxxxxx>
>
>