Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xhci: Set quirky xHC PCI hosts to D3 _after_ stopping and freeing them.

PCI xHC host should be stopped and xhci driver memory freed before putting
host to PCI D3 state during PCI remove callback.

Hosts with XHCI_SPURIOUS_WAKEUP quirk did this the wrong way around
and set the host to D3 before calling usb_hcd_pci_remove(dev), which will
access the host to stop it, and then free xhci.

Fixes: f1f6d9a8b540 ("xhci: don't dereference a xhci member after removing xhci")
Cc: stable@vger.kernel.org
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20240905143300.1959279-12-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Mathias Nyman and committed by
Greg Kroah-Hartman
f81dfa3b da6a6dcf

+6 -4
+6 -4
drivers/usb/host/xhci-pci.c
··· 657 657 void xhci_pci_remove(struct pci_dev *dev) 658 658 { 659 659 struct xhci_hcd *xhci; 660 + bool set_power_d3; 660 661 661 662 xhci = hcd_to_xhci(pci_get_drvdata(dev)); 663 + set_power_d3 = xhci->quirks & XHCI_SPURIOUS_WAKEUP; 662 664 663 665 xhci->xhc_state |= XHCI_STATE_REMOVING; 664 666 ··· 673 671 xhci->shared_hcd = NULL; 674 672 } 675 673 676 - /* Workaround for spurious wakeups at shutdown with HSW */ 677 - if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) 678 - pci_set_power_state(dev, PCI_D3hot); 679 - 680 674 usb_hcd_pci_remove(dev); 675 + 676 + /* Workaround for spurious wakeups at shutdown with HSW */ 677 + if (set_power_d3) 678 + pci_set_power_state(dev, PCI_D3hot); 681 679 } 682 680 EXPORT_SYMBOL_NS_GPL(xhci_pci_remove, xhci); 683 681