]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
usb: gadget: udc: core: Prevent redundant calls to pullup
authorBadhri Jagan Sridharan <badhri@google.com>
Fri, 7 Apr 2023 03:07:41 +0000 (03:07 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:10:49 +0000 (23:10 +0900)
commit a3afbf5cc887fc3401f012fe629810998ed61859 upstream.

usb_gadget_connect calls gadget->ops->pullup without checking whether
gadget->connected was previously set. Make this symmetric to
usb_gadget_disconnect by returning early if gadget->connected is
already set.

Fixes: 5a1da544e572 ("usb: gadget: core: do not try to disconnect gadget if it is not connected")
Cc: stable@vger.kernel.org
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Link: https://lore.kernel.org/r/20230407030741.3163220-2-badhri@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/udc/core.c

index ebb2b839b470b64c20a21f817c943f5e4750bc88..b14cbd0a6d013ca7d2dd114cbcdccf56c63d950d 100644 (file)
@@ -676,6 +676,9 @@ static int usb_gadget_connect_locked(struct usb_gadget *gadget)
                goto out;
        }
 
+       if (gadget->connected)
+               goto out;
+
        if (gadget->deactivated || !gadget->udc->started) {
                /*
                 * If gadget is deactivated we only save new state.