[PATCH 2/2] usb: dwc3: gadget: Check if the gadget had stopped

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If the gadget had already stopped, don't try to stop again. Otherwise
we'd get a warning for trying to free an already freed irq. This can
happen if a user tries to trigger a soft-disconnect from soft_connect
sysfs multiple times. The fix is to check if there's a bounded gadget
driver to determined if the gadget had stopped.

Cc: stable@xxxxxxxxxxxxxxx
Fixes: 8698e2acf3a5 ("usb: dwc3: gadget: introduce and use enable/disable irq methods")
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx>
---
 drivers/usb/dwc3/gadget.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 51d81a32ce78..9ec70282e610 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2338,6 +2338,10 @@ static int dwc3_gadget_stop(struct usb_gadget *g)
 	struct dwc3		*dwc = gadget_to_dwc(g);
 	unsigned long		flags;
 
+	/* The controller is already stopped if there's no gadget driver */
+	if (!dwc->gadget_driver)
+		return 0;
+
 	spin_lock_irqsave(&dwc->lock, flags);
 	dwc->gadget_driver	= NULL;
 	spin_unlock_irqrestore(&dwc->lock, flags);
-- 
2.28.0




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux