2023-07-21 22:30:30

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH] usb: gadget: core: remove unbalanced mutex_unlock in usb_gadget_activate

Commit 286d9975a838 ("usb: gadget: udc: core: Prevent soft_connect_store() race")
introduced one extra mutex_unlock of connect_lock in the usb_gadget_active function.

Fixes: 286d9975a838 ("usb: gadget: udc: core: Prevent soft_connect_store() race")
Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/usb/gadget/udc/core.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 59188ea065e0c9..cd58f2a4e7f34d 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -878,7 +878,6 @@ int usb_gadget_activate(struct usb_gadget *gadget)
*/
if (gadget->connected)
ret = usb_gadget_connect_locked(gadget);
- mutex_unlock(&gadget->udc->connect_lock);

unlock:
mutex_unlock(&gadget->udc->connect_lock);
--
2.39.2



2023-07-24 14:58:00

by Alan Stern

[permalink] [raw]
Subject: Re: [PATCH] usb: gadget: core: remove unbalanced mutex_unlock in usb_gadget_activate

On Sat, Jul 22, 2023 at 12:22:56AM +0200, Michael Grzeschik wrote:
> Commit 286d9975a838 ("usb: gadget: udc: core: Prevent soft_connect_store() race")
> introduced one extra mutex_unlock of connect_lock in the usb_gadget_active function.
>
> Fixes: 286d9975a838 ("usb: gadget: udc: core: Prevent soft_connect_store() race")
> Signed-off-by: Michael Grzeschik <[email protected]>
> ---

Hard to see how we missed that...

Reviewed-by: Alan Stern <[email protected]>

Thanks!

> drivers/usb/gadget/udc/core.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> index 59188ea065e0c9..cd58f2a4e7f34d 100644
> --- a/drivers/usb/gadget/udc/core.c
> +++ b/drivers/usb/gadget/udc/core.c
> @@ -878,7 +878,6 @@ int usb_gadget_activate(struct usb_gadget *gadget)
> */
> if (gadget->connected)
> ret = usb_gadget_connect_locked(gadget);
> - mutex_unlock(&gadget->udc->connect_lock);
>
> unlock:
> mutex_unlock(&gadget->udc->connect_lock);
> --
> 2.39.2
>