mirror-linux/drivers/usb/host
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
..
Kconfig usb: host: xhci-rcar: Add Renesas RZ/G3E USB3 Host driver support 2025-09-17 12:43:18 +02:00
Makefile xhci: sideband: add initial api to register a secondary interrupter entity 2025-04-11 13:02:29 +02:00
bcma-hcd.c
ehci-atmel.c
ehci-brcm.c
ehci-dbg.c
ehci-exynos.c
ehci-fsl.c usb: ehci-fsl: Fix use of private data to avoid -Wflex-array-member-not-at-end warning 2025-04-11 16:08:33 +02:00
ehci-fsl.h
ehci-grlib.c
ehci-hcd.c usb: ehci: Switch to use hrtimer_setup() 2025-02-18 11:19:02 +01:00
ehci-hub.c
ehci-mem.c
ehci-mv.c
ehci-npcm7xx.c
ehci-omap.c
ehci-orion.c
ehci-pci.c
ehci-platform.c usb: host: ehci-platform: Call reset assert/deassert on suspend/resume 2025-11-21 15:11:22 +01:00
ehci-ppc-of.c
ehci-ps3.c
ehci-q.c
ehci-sched.c
ehci-sh.c usb: ehci-hcd: fix call balance of clocks handling routines 2024-12-04 16:25:13 +01:00
ehci-spear.c usb: ehci-spear: fix call balance of sehci clk handling routines 2024-11-16 09:04:06 +01:00
ehci-st.c
ehci-sysfs.c usb: ehci: replace scnprintf() with sysfs_emit() 2025-06-24 15:40:19 +01:00
ehci-timer.c
ehci-xilinx-of.c
ehci.h
fhci-dbg.c
fhci-hcd.c
fhci-hub.c
fhci-mem.c
fhci-q.c
fhci-sched.c
fhci-tds.c
fhci.h
fsl-mph-dr-of.c usb: fsl-mph-dr-of: Remove unnecessary NULL check before clk_disable_unprepare() 2025-06-19 12:27:29 +02:00
isp116x-hcd.c
isp116x.h
isp1362-hcd.c treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
isp1362.h
max3421-hcd.c usb: host: max3421-hcd: Fix error pointer dereference in probe cleanup 2025-08-13 16:55:48 +02:00
octeon-hcd.c
octeon-hcd.h
ohci-at91.c usb: ohci-at91: Use dynamic device name for OHCI HCD creation 2025-06-19 12:27:33 +02:00
ohci-da8xx.c usb: ohci-da8xx: remove unused platform data 2025-11-21 15:13:56 +01:00
ohci-dbg.c
ohci-exynos.c
ohci-hcd.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
ohci-hub.c treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
ohci-mem.c
ohci-nxp.c usb: ohci-nxp: clean up probe error labels 2025-12-23 15:48:46 +01:00
ohci-omap.c
ohci-pci.c USB: OHCI: Add quirk for LS7A OHCI controller (rev 0x02) 2025-04-11 16:21:20 +02:00
ohci-platform.c USB: OHCI/UHCI: Add soft dependencies on ehci_platform 2026-01-14 16:02:14 +01:00
ohci-ppc-of.c
ohci-ps3.c
ohci-pxa27x.c
ohci-q.c
ohci-s3c2410.c usb: ohci: s3c2410: Drop support for S3C2410 systems 2025-09-06 15:22:51 +02:00
ohci-sa1111.c
ohci-sm501.c
ohci-spear.c usb: ohci-spear: Remove unnecessary NULL check before clk_disable_unprepare() 2025-06-19 12:27:26 +02:00
ohci-st.c
ohci.h
oxu210hp-hcd.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
pci-quirks.c USB: pci-quirks: Fix HCCPARAMS register error for LS7A EHCI 2025-02-14 09:18:14 +01:00
pci-quirks.h
r8a66597-hcd.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
r8a66597.h
sl811-hcd.c usb: sl811-hcd: Add PM_EVENT_POWEROFF into suspend callbacks 2025-11-14 17:05:53 +01:00
sl811.h
sl811_cs.c
ssb-hcd.c
uhci-debug.c
uhci-grlib.c
uhci-hcd.c treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
uhci-hcd.h usb: uhci: Add reset control support 2025-10-13 09:11:49 +02:00
uhci-hub.c
uhci-pci.c
uhci-platform.c USB: OHCI/UHCI: Add soft dependencies on ehci_platform 2026-01-14 16:02:14 +01:00
uhci-q.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
xen-hcd.c xen/usb: Constify struct hc_driver 2025-10-28 15:35:15 +01:00
xhci-caps.h usb: xhci: Add debugfs support for xHCI Port Link Info (PORTLI) register. 2025-11-21 14:53:01 +01:00
xhci-dbg.c
xhci-dbgcap.c usb: xhci: replace use of system_wq with system_percpu_wq 2025-11-21 14:53:00 +01:00
xhci-dbgcap.h xhci: dbgtty: Fix data corruption when transmitting data form DbC to host 2025-11-09 10:54:44 +09:00
xhci-dbgtty.c xhci: dbgtty: fix device unregister: fixup 2025-12-17 14:48:42 +01:00
xhci-debugfs.c usb: xhci: Add debugfs support for xHCI Port Link Info (PORTLI) register. 2025-11-21 14:53:01 +01:00
xhci-debugfs.h
xhci-ext-caps.c
xhci-ext-caps.h
xhci-histb.c usb: xhci: change xhci_resume() parameters to explicit the desired info 2025-03-14 09:18:02 +01:00
xhci-hub.c usb: xhci: standardize single bit-field macros 2025-11-21 14:53:01 +01:00
xhci-mem.c usb: xhci: standardize single bit-field macros 2025-11-21 14:53:01 +01:00
xhci-mtk-sch.c
xhci-mtk.c usb: Remove redundant pm_runtime_mark_last_busy() calls 2025-11-21 15:11:53 +01:00
xhci-mtk.h usb: xhci-mtk: correct most kernel-doc problems in xhci-mtk.h 2025-11-21 14:52:37 +01:00
xhci-mvebu.c usb: host: xhci-plat: mvebu: use ->quirks instead of ->init_quirk() func 2025-03-14 09:18:02 +01:00
xhci-mvebu.h usb: host: xhci-plat: mvebu: use ->quirks instead of ->init_quirk() func 2025-03-14 09:18:02 +01:00
xhci-pci-renesas.c usb: renesas-xhci: Fix External ROM access timeouts 2025-08-13 17:15:59 +02:00
xhci-pci.c usb: xhci: simplify handling of Structural Parameters 1 values 2025-11-21 14:53:00 +01:00
xhci-pci.h
xhci-plat.c usb: host: xhci-plat: Add .post_resume_quirk for struct xhci_plat_priv 2025-09-17 12:43:17 +02:00
xhci-plat.h usb: host: xhci-plat: Add .post_resume_quirk for struct xhci_plat_priv 2025-09-17 12:43:17 +02:00
xhci-port.h usb: xhci: Add debugfs support for xHCI Port Link Info (PORTLI) register. 2025-11-21 14:53:01 +01:00
xhci-rcar-regs.h usb: host: xhci-rcar: Move R-Car reg definitions 2025-09-17 12:43:16 +02:00
xhci-rcar.c usb: host: xhci-rcar: Add Renesas RZ/G3E USB3 Host driver support 2025-09-17 12:43:18 +02:00
xhci-ring.c USB/Thunderbolt changes for 6.19-rc1 2025-12-06 18:42:12 -08:00
xhci-rzg3e-regs.h usb: host: xhci-rcar: Add Renesas RZ/G3E USB3 Host driver support 2025-09-17 12:43:18 +02:00
xhci-rzv2m.c
xhci-rzv2m.h
xhci-sideband.c xhci: sideband: don't dereference freed ring when removing sideband endpoint 2026-01-16 12:19:37 +01:00
xhci-tegra.c usb: host: xhci-tegra: Use platform_get_irq_optional() for wake IRQs 2026-01-14 16:02:28 +01:00
xhci-trace.c
xhci-trace.h usb: xhci: standardize single bit-field macros 2025-11-21 14:53:01 +01:00
xhci.c xhci: sideband: don't dereference freed ring when removing sideband endpoint 2026-01-16 12:19:37 +01:00
xhci.h usb: xhci: limit number of interrupts to 128 2025-11-21 14:53:00 +01:00