linux-yocto/drivers/usb
Weitao Wang c78c8e5048 usb: xhci: Fix slot_id resource race conflict
[ Upstream commit 2eb03376151bb8585caa23ed2673583107bb5193 ]

xHC controller may immediately reuse a slot_id after it's disabled,
giving it to a new enumerating device before the xhci driver freed
all resources related to the disabled device.

In such a scenario, device-A with slot_id equal to 1 is disconnecting
while device-B is enumerating, device-B will fail to enumerate in the
follow sequence.

1.[device-A] send disable slot command
2.[device-B] send enable slot command
3.[device-A] disable slot command completed and wakeup waiting thread
4.[device-B] enable slot command completed with slot_id equal to 1 and
	     wakeup waiting thread
5.[device-B] driver checks that slot_id is still in use (by device-A) in
	     xhci_alloc_virt_device, and fail to enumerate due to this
	     conflict
6.[device-A] xhci->devs[slot_id] set to NULL in xhci_free_virt_device

To fix driver's slot_id resources conflict, clear xhci->devs[slot_id] and
xhci->dcbba->dev_context_ptrs[slot_id] pointers in the interrupt context
when disable slot command completes successfully. Simultaneously, adjust
function xhci_free_virt_device to accurately handle device release.

[minor smatch warning and commit message fix -Mathias]

Cc: stable@vger.kernel.org
Fixes: 7faac1953e ("xhci: avoid race between disable slot command and host runtime suspend")
Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20250819125844.2042452-2-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-08-28 16:24:37 +02:00
..
atm usb: atm: cxacru: Merge cxacru_upload_firmware() into cxacru_heavy_init() 2025-08-28 16:24:27 +02:00
c67x00
cdns3 usb: cdnsp: Fix issue with CV Bad Descriptor test 2025-07-17 18:30:51 +02:00
chipidea usb: chipidea: add USB PHY event 2025-08-28 16:24:05 +02:00
class cdc-acm: fix race between initial clearing halt and open 2025-08-28 16:24:26 +02:00
common usb: common: usb-conn-gpio: use a unique name for usb connector device 2025-07-10 15:57:33 +02:00
core usb: core: hcd: fix accessing unmapped memory in SINGLE_STEP_SET_FEATURE test 2025-08-28 16:24:35 +02:00
dwc2 usb: dwc2: also exit clock_gating when stopping udc while suspended 2025-07-10 15:57:33 +02:00
dwc3 usb: dwc3: Remove WARN_ON for device endpoint command timeouts 2025-08-28 16:24:35 +02:00
early usb: early: xhci-dbc: Fix early_ioremap leak 2025-08-28 16:24:06 +02:00
gadget usb: gadget: udc: renesas_usb3: fix device leak at unbind 2025-08-28 16:24:27 +02:00
host usb: xhci: Fix slot_id resource race conflict 2025-08-28 16:24:37 +02:00
image
isp1760
misc usb: misc: apple-mfi-fastcharge: Make power supply names unique 2025-08-28 16:24:06 +02:00
mon
mtu3
musb usb: musb: omap2430: fix device leak at unbind 2025-08-28 16:24:32 +02:00
phy usb: phy: mxs: disconnect line when USB charger is attached 2025-08-28 16:24:05 +02:00
renesas_usbhs usb: renesas_usbhs: Reorder clock handling and power management in probe 2025-06-27 11:05:16 +01:00
roles
serial USB: serial: option: add Foxconn T99W709 2025-08-28 16:24:14 +02:00
storage USB: storage: Ignore driver CD mode for Realtek multi-mode Wi-Fi dongles 2025-08-28 16:24:35 +02:00
typec usb: typec: fusb302: cache PD RX state 2025-08-28 16:24:31 +02:00
usbip
Kconfig
Makefile
usb-skeleton.c