linux/drivers/usb/dwc3
Runyu Xiao 010382937f usb: dwc3: run gadget disconnect from sleepable suspend context
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>
2026-07-08 13:35:22 +02:00
..
core.c usb: dwc3: fix dwc3_readl() and dwc3_writel() calls in dwc3_ulpi_setup() 2026-07-08 13:33:43 +02:00
core.h usb: dwc3: fix a typo 'HishSpeed' 2026-03-11 15:13:56 +01:00
debug.h usb: dwc3: Add trace event for dwc3_set_prtcap 2025-09-06 15:21:59 +02:00
debugfs.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
drd.c usb: dwc3: Add dwc pointer to dwc3_readl/writel 2026-01-16 13:47:07 +01:00
dwc3-am62.c usb: Remove redundant pm_runtime_mark_last_busy() calls 2025-11-21 15:11:53 +01:00
dwc3-apple.c usb: dwc3: apple: Ignore USB role switches to the active role 2026-01-14 16:02:54 +01:00
dwc3-exynos.c usb: dwc3-exynos: add support for ExynosAutov920 2025-05-21 13:12:43 +02:00
dwc3-generic-plat.c usb: dwc3: starfive: Add JHB100 USB 2.0 DRD controller 2026-04-11 12:02:43 +02:00
dwc3-google.c usb: dwc3: google: Use FIELD_MODIFY() 2026-05-21 16:43:04 +02:00
dwc3-haps.c
dwc3-imx.c usb: dwc3: imx: avoid calling imx suspend/resume callbacks twice 2026-03-18 16:22:18 +01:00
dwc3-imx8mp.c usb: dwc3: imx8mp: fix memory leak on probe failure path 2026-04-02 09:37:45 +02:00
dwc3-keystone.c usb: Switch back to struct platform_driver::remove() 2024-10-04 15:13:03 +02:00
dwc3-meson-g12a.c usb: dwc3: meson-g12a: fix refcount leak in dwc3_meson_g12a_resume() 2026-06-25 16:04:11 +01:00
dwc3-octeon.c usb: dwc3: dwc3-octeon: Use FIELD_MODIFY() 2026-05-21 16:43:04 +02:00
dwc3-of-simple.c usb: dwc3: of-simple: fix clock resource leak in dwc3_of_simple_probe 2025-12-17 14:54:38 +01:00
dwc3-omap.c usb: dwc3: omap: Fix devm_regulator_get_optional() error handling 2025-01-11 17:02:30 +01:00
dwc3-pci.c usb: dwc3: pci: add support for the Intel Nova Lake -H 2026-03-11 16:19:41 +01:00
dwc3-qcom-legacy.c usb: dwc3: qcom: Snapshot driver for backwards compatibilty 2025-04-15 14:29:19 +02:00
dwc3-qcom.c usb: dwc3: qcom: simplify error check in dwc3_qcom_find_num_ports() 2026-03-11 15:23:37 +01:00
dwc3-rtk.c usb: Switch back to struct platform_driver::remove() 2024-10-04 15:13:03 +02:00
dwc3-st.c usb: dwc3: Don't use %pK through printk 2025-03-14 09:17:30 +01:00
dwc3-xilinx.c usb: dwc3: xilinx: fix error handling in zynqmp init error paths 2026-05-21 16:40:50 +02:00
ep0.c usb: dwc3: Log dwc3 address in traces 2026-01-27 15:52:45 +01:00
gadget.c usb: dwc3: run gadget disconnect from sleepable suspend context 2026-07-08 13:35:22 +02:00
gadget.h usb: dwc3: Add dwc pointer to dwc3_readl/writel 2026-01-16 13:47:07 +01:00
glue.h usb: dwc3: add needs_full_reinit flag 2026-02-25 10:35:58 -08:00
host.c usb: dwc3: keep susphy enabled during exit to avoid controller faults 2025-12-17 14:49:18 +01:00
io.h usb: dwc3: Log dwc3 address in traces 2026-01-27 15:52:45 +01:00
Kconfig usb: dwc3: introduce flatten model driver of i.MX Soc 2026-02-25 10:35:58 -08:00
Makefile usb: dwc3: introduce flatten model driver of i.MX Soc 2026-02-25 10:35:58 -08:00
trace.c
trace.h usb: dwc3: Log dwc3 address in traces 2026-01-27 15:52:45 +01:00
ulpi.c usb: dwc3: Support USB3340x ULPI PHY high-speed negotiation. 2026-03-11 15:00:28 +01:00