[PATCH] usb: gadget: pch_udc: Initialize spinlock before registering IRQ

From: Runyu Xiao

Date: Sat Aug 29 2026 - 22:15:24 EST


pch_udc_probe() initializes dev->lock after pch_udc_pcd_init()
registers the optional VBUS GPIO IRQ. It also requests the PCI IRQ before
initializing the lock. Both interrupt paths can run during probe, and the
controller interrupt handler takes dev->lock.

Initialize the lock before pch_udc_pcd_init() so every registered callback
observes an initialized lock.

Fixes: f646cf94520e ("USB device driver of Topcliff PCH")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Runyu Xiao <runyu.xiao@xxxxxxxxxx>
Assisted-by: Codex:GPT-5
---
drivers/usb/gadget/udc/pch_udc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
index 99b3ce282..e5321d0dd 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -3067,6 +3067,7 @@ static int pch_udc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
return retval;

dev->base_addr = pcim_iomap_table(pdev)[dev->bar];
+ spin_lock_init(&dev->lock);

/* initialize the hardware */
retval = pch_udc_pcd_init(dev);
@@ -3087,7 +3088,6 @@ static int pch_udc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
pci_try_set_mwi(pdev);

/* device struct setup */
- spin_lock_init(&dev->lock);
dev->gadget.ops = &pch_udc_ops;

retval = init_dma_pools(dev);
--
2.34.1