mirror-linux/drivers/usb
Mathias Nyman dd83dc1249 xhci: sideband: don't dereference freed ring when removing sideband endpoint
xhci_sideband_remove_endpoint() incorrecly assumes that the endpoint is
running and has a valid transfer ring.

Lianqin reported a crash during suspend/wake-up stress testing, and
found the cause to be dereferencing a non-existing transfer ring
'ep->ring' during xhci_sideband_remove_endpoint().

The endpoint and its ring may be in unknown state if this function
is called after xHCI was reinitialized in resume (lost power), or if
device is being re-enumerated, disconnected or endpoint already dropped.

Fix this by both removing unnecessary ring access, and by checking
ep->ring exists before dereferencing it. Also make sure endpoint is
running before attempting to stop it.

Remove the xhci_initialize_ring_info() call during sideband endpoint
removal as is it only initializes ring structure enqueue, dequeue and
cycle state values to their starting values without changing actual
hardware enqueue, dequeue and cycle state. Leaving them out of sync
is worse than leaving it as it is. The endpoint will get freed in after
this in most usecases.

If the (audio) class driver want's to reuse the endpoint after offload
then it is up to the class driver to ensure endpoint is properly set up.

Reported-by: 胡连勤 <hulianqin@vivo.com>
Closes: https://lore.kernel.org/linux-usb/TYUPR06MB6217B105B059A7730C4F6EC8D2B9A@TYUPR06MB6217.apcprd06.prod.outlook.com/
Tested-by: 胡连勤 <hulianqin@vivo.com>
Fixes: de66754e9f ("xhci: sideband: add initial api to register a secondary interrupter entity")
Cc: stable@vger.kernel.org
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20260115233758.364097-2-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-01-16 12:19:37 +01:00
..
atm usb: atm: cxacru: Merge cxacru_upload_firmware() into cxacru_heavy_init() 2025-07-24 11:33:31 +02:00
c67x00
cdns3 USB/Thunderbolt changes for 6.19-rc1 2025-12-06 18:42:12 -08:00
chipidea USB/Thunderbolt changes for 6.19-rc1 2025-12-06 18:42:12 -08:00
class uapi: cdc.h: cleanly provide for more interfaces and countries 2025-11-21 15:12:12 +01:00
common
core usb: core: add USB_QUIRK_NO_BOS for devices that hang on BOS descriptor 2026-01-07 17:07:00 +01:00
dwc2 usb: dwc2: fix hang during suspend if set as peripheral 2025-11-21 15:10:38 +01:00
dwc3 usb: dwc3: apple: Ignore USB role switches to the active role 2026-01-14 16:02:54 +01:00
early usb: early: xhci-dbc: Fix early_ioremap leak 2025-07-07 11:04:46 +02:00
fotg210
gadget usb: gadget: uvc: retry vb2_reqbufs() with vb_vmalloc_memops if use_sg fail 2026-01-14 16:03:18 +01:00
host xhci: sideband: don't dereference freed ring when removing sideband endpoint 2026-01-16 12:19:37 +01:00
image
isp1760
misc usb: Remove redundant pm_runtime_mark_last_busy() calls 2025-11-21 15:11:53 +01:00
mon usb: mon: Increase BUFF_MAX to 64 MiB to support multi-MB URBs 2025-09-17 12:40:05 +02:00
mtu3 usb: Remove redundant pm_runtime_mark_last_busy() calls 2025-11-21 15:11:53 +01:00
musb usb: Remove redundant pm_runtime_mark_last_busy() calls 2025-11-21 15:11:53 +01:00
phy usb: phy: isp1301: fix non-OF device reference imbalance 2025-12-23 15:48:46 +01:00
renesas_usbhs usb: renesas_usbhs: Fix a resource leak in usbhs_pipe_malloc() 2025-12-17 14:51:54 +01:00
roles
serial USB: serial: f81232: fix incomplete serial port generation 2026-01-13 15:59:07 +01:00
storage usb: usb-storage: Maintain minimal modifications to the bcdDevice range. 2025-12-23 15:41:31 +01:00
typec tcpm: allow looking for role_sw device in the main node 2026-01-07 16:28:05 +01:00
usbip usbip: Use min to simplify stub_send_ret_submit 2025-10-22 10:58:31 +02:00
Kconfig
Makefile
usb-skeleton.c