aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThinh Nguyen <[email protected]>2024-02-16 00:41:02 +0000
committerGreg Kroah-Hartman <[email protected]>2024-02-19 09:30:42 +0100
commitb191a18cb5c47109ca696370a74a5062a70adfd0 (patch)
tree9b1b88896860cf797a86efdbc655e43da7f159d9
parent5fd9e45f1ebcd57181358af28506e8a661a260b3 (diff)
usb: dwc3: gadget: Don't disconnect if not started
Don't go through soft-disconnection sequence if the controller hasn't started. Otherwise, there will be timeout and warning reports from the soft-disconnection flow. Cc: [email protected] Fixes: 61a348857e86 ("usb: dwc3: gadget: Fix NULL pointer dereference in dwc3_gadget_suspend") Reported-by: Marek Szyprowski <[email protected]> Closes: https://lore.kernel.org/linux-usb/[email protected]/T/#mb0661cd5f9272602af390c18392b9a36da4f96e6 Tested-by: Marek Szyprowski <[email protected]> Signed-off-by: Thinh Nguyen <[email protected]> Link: https://lore.kernel.org/r/e3be9b929934e0680a6f4b8f6eb11b18ae9c7e07.1708043922.git.Thinh.Nguyen@synopsys.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r--drivers/usb/dwc3/gadget.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 4c8dd6724678..28f49400f3e8 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2650,6 +2650,11 @@ static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc)
int ret;
spin_lock_irqsave(&dwc->lock, flags);
+ if (!dwc->pullups_connected) {
+ spin_unlock_irqrestore(&dwc->lock, flags);
+ return 0;
+ }
+
dwc->connected = false;
/*