linux/drivers/usb/dwc2
Juno Choi e9fcca3e87 usb: dwc2: gadget: Fix spin_lock/unlock mismatch in dwc2_hsotg_udc_stop()
commit 9bb4b5ed7f upstream.

dwc2_gadget_exit_clock_gating() internally calls call_gadget() macro,
which expects hsotg->lock to be held since it does spin_unlock/spin_lock
around the gadget driver callback invocation.

However, dwc2_hsotg_udc_stop() calls dwc2_gadget_exit_clock_gating()
without holding the lock. This leads to:
 - spin_unlock on a lock that is not held (undefined behavior)
 - The lock remaining held after dwc2_gadget_exit_clock_gating() returns,
   causing a deadlock when spin_lock_irqsave() is called later in the
   same function.

Fix this by acquiring hsotg->lock before calling
dwc2_gadget_exit_clock_gating() and releasing it afterwards, which
satisfies the locking requirement of the call_gadget() macro.

Fixes: af076a41f8 ("usb: dwc2: also exit clock_gating when stopping udc while suspended")
Cc: stable <stable@kernel.org>
Signed-off-by: Juno Choi <juno.choi@lge.com>
Link: https://patch.msgid.link/20260324014910.2798425-1-juno.choi@lge.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-04-18 10:33:33 +02:00
..
core.c usb: dwc2: fix resume failure if dr_mode is host 2026-03-04 07:20:33 -05:00
core.h usb: dwc2: gadget: LPM flow fix 2024-04-10 16:19:33 +02:00
core_intr.c usb: dwc2: gadget: LPM flow fix 2024-04-10 16:19:33 +02:00
debug.h USB: dwc2: Use the correct style for SPDX License Identifier 2020-05-05 10:58:50 +03:00
debugfs.c usb: dwc2: Add STM32 related debugfs entries 2021-03-10 09:37:15 +01:00
drd.c usb: dwc2: drd: fix clock gating on USB role switch 2024-10-17 15:11:12 +02:00
gadget.c usb: dwc2: gadget: Fix spin_lock/unlock mismatch in dwc2_hsotg_udc_stop() 2026-04-18 10:33:33 +02:00
hcd.c usb: dwc2: Fix HCD port connection race 2024-12-19 18:07:17 +01:00
hcd.h USB: dwc2: Use the correct style for SPDX License Identifier 2020-05-05 10:58:50 +03:00
hcd_ddma.c usb: dwc2: host: Fix dereference issue in DDMA completion flow. 2024-04-27 17:05:27 +02:00
hcd_intr.c USB: dwc2: write HCINT with INTMASK applied 2023-12-03 07:31:25 +01:00
hcd_queue.c usb: dwc2: hcd_queue: Fix use of floating point literal 2021-12-01 09:04:39 +01:00
hw.h usb: dwc2: host: Fix ISOC flow in DDMA mode 2024-04-10 16:19:33 +02:00
Kconfig usb: dwc2: override PHY input signals with usb role switch support 2020-10-02 13:29:13 +03:00
Makefile usb: dwc2: override PHY input signals with usb role switch support 2020-10-02 13:29:13 +03:00
params.c usb: dwc2: Skip clock gating on Samsung SoCs 2021-07-21 09:50:27 +02:00
pci.c usb: dwc2: pci: Fix possible copy/paste issue 2021-05-27 09:45:27 +02:00
platform.c usb: dwc2: fix hang during suspend if set as peripheral 2026-01-19 13:09:32 +01:00