linux/drivers/usb
Runyu Xiao b399be2958 usb: dwc3: run gadget disconnect from sleepable suspend context
commit 010382937f upstream.

dwc3_gadget_suspend() takes dwc->lock with IRQs disabled and then calls
dwc3_disconnect_gadget().  For async callbacks that helper only uses
plain spin_unlock()/spin_lock(), so the gadget ->disconnect() callback
still runs with IRQs disabled and any sleepable callback trips Lockdep.

This issue was found by our static analysis tool and then manually
reviewed against the current tree.

The grounded PoC kept the dwc3_gadget_suspend() ->
dwc3_disconnect_gadget() -> gadget_driver->disconnect() chain, and
Lockdep reported:

  BUG: sleeping function called from invalid context
  gadget_disconnect+0x21/0x39 [vuln_msv]
  dwc3_gadget_suspend.constprop.0+0x2b/0x42 [vuln_msv]

Keep the disconnect callback selection in one common helper, but add a
sleepable suspend-side wrapper which snapshots the callback under
dwc->lock and then runs it after spin_unlock_irqrestore().  The regular
event path still uses the existing spin_unlock()/spin_lock() window.

Fixes: c8540870af ("usb: dwc3: gadget: Improve dwc3_gadget_suspend() and dwc3_gadget_resume()")
Cc: stable <stable@kernel.org>
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://patch.msgid.link/20260612052005.3849659-1-runyu.xiao@seu.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-07-24 15:51:20 +02:00
..
atm usb: atm: cxacru: Merge cxacru_upload_firmware() into cxacru_heavy_init() 2025-08-28 16:24:27 +02:00
c67x00 usb/c67x00: Replace tasklet with work 2021-01-26 18:36:37 +01:00
cdns3 usb: cdns3: plat: fix leaked usb2_phy initialization on usb3_phy acquisition failure 2026-06-19 13:33:47 +02:00
chipidea usb: chipidea: core: convert ci_role_switch to local variable 2026-06-19 13:33:29 +02:00
class usb: usbtmc: reject interrupt endpoints with small wMaxPacketSize 2026-06-19 13:33:30 +02:00
common usb: ulpi: fix memory leak on ulpi_register() error paths 2026-06-01 17:35:20 +02:00
core usb: core: Fix SuperSpeed root hub wMaxPacketSize 2026-06-19 13:33:32 +02:00
dwc2 usb: dwc2: Fix use after free in debug code 2026-06-19 13:33:27 +02:00
dwc3 usb: dwc3: run gadget disconnect from sleepable suspend context 2026-07-24 15:51:20 +02:00
early usb: early: xhci-dbc: Fix early_ioremap leak 2025-08-28 16:24:06 +02:00
gadget usb: gadget: function: rndis: add length check for header 2026-07-24 15:51:18 +02:00
host usb: xhci: Fix sleep in atomic context in xhci_free_streams() 2026-07-24 15:51:19 +02:00
image usb: image: mdc800: kill download URB on timeout 2026-04-18 10:33:14 +02:00
isp1760 usb: isp1760: Fix out-of-bounds array access 2022-06-09 10:22:27 +02:00
misc USB: chaoskey: Fix slab-use-after-free in chaoskey_release() 2026-07-24 15:51:20 +02:00
mon usb: mon: Increase BUFF_MAX to 64 MiB to support multi-MB URBs 2025-12-07 06:09:22 +09:00
mtu3 usb: mtu3: fix kernel panic at qmu transfer done irq handler 2023-05-11 23:00:33 +09:00
musb usb: musb: omap2430: fix device leak at unbind 2025-08-28 16:24:32 +02:00
phy usb: phy: isp1301: fix non-OF device reference imbalance 2026-01-19 13:09:50 +01:00
renesas_usbhs usb: renesas_usbhs: fix use-after-free in ISR during device removal 2026-04-18 10:33:14 +02:00
roles usb: roles: set switch registered flag early on 2025-03-13 12:50:37 +01:00
serial USB: serial: kl5kusb105: fix bulk-out buffer overflow 2026-06-19 13:33:36 +02:00
storage usb: storage: Add quirks for PNY Elite Portable SSD 2026-06-19 13:33:29 +02:00
typec usb: typec: ucsi: Check if power role change actually happened before handling 2026-06-19 13:33:48 +02:00
usbip use less confusing names for iov_iter direction initializers 2026-06-19 13:33:46 +02:00
Kconfig usb: remove reference to deleted config STB03xxx 2021-08-18 15:32:19 +02:00
Makefile usb: host: remove line for obsolete config USB_HWA_HCD 2021-08-18 15:32:19 +02:00
usb-skeleton.c USB: usb-skeleton: drop redundant in-urb check 2019-10-10 12:41:19 +02:00