diff mbox series

usb: gadget: udc: core: Fix double unlock in usb_gadget_activate()

Message ID 32e22952-8574-4120-979b-ebb6af5f54b4@moroto.mountain (mailing list archive)
State New, archived
Headers show
Series usb: gadget: udc: core: Fix double unlock in usb_gadget_activate() | expand

Commit Message

Dan Carpenter June 15, 2023, 3:43 p.m. UTC
Do not call mutex_unlock(&gadget->udc->connect_lock) twice in a row.

Fixes: 286d9975a838 ("usb: gadget: udc: core: Prevent soft_connect_store() race")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/usb/gadget/udc/core.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Badhri Jagan Sridharan June 15, 2023, 6:10 p.m. UTC | #1
Thanks Dan for posting this !

Regards,
Badhri

On Thu, Jun 15, 2023 at 8:43 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> Do not call mutex_unlock(&gadget->udc->connect_lock) twice in a row.
>
> Fixes: 286d9975a838 ("usb: gadget: udc: core: Prevent soft_connect_store() race")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>

> ---
>  drivers/usb/gadget/udc/core.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> index 83fd1de14784..d58640a9d0ca 100644
> --- a/drivers/usb/gadget/udc/core.c
> +++ b/drivers/usb/gadget/udc/core.c
> @@ -878,8 +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);
>         trace_usb_gadget_activate(gadget, ret);
> --
> 2.39.2
>
Greg KH June 19, 2023, 1:39 p.m. UTC | #2
On Thu, Jun 15, 2023 at 06:43:03PM +0300, Dan Carpenter wrote:
> Do not call mutex_unlock(&gadget->udc->connect_lock) twice in a row.
> 
> Fixes: 286d9975a838 ("usb: gadget: udc: core: Prevent soft_connect_store() race")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/usb/gadget/udc/core.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> index 83fd1de14784..d58640a9d0ca 100644
> --- a/drivers/usb/gadget/udc/core.c
> +++ b/drivers/usb/gadget/udc/core.c
> @@ -878,8 +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);
>  	trace_usb_gadget_activate(gadget, ret);
> -- 
> 2.39.2
> 

Does not apply to my tree :(
Dan Carpenter June 19, 2023, 2:46 p.m. UTC | #3
On Mon, Jun 19, 2023 at 03:39:05PM +0200, Greg Kroah-Hartman wrote:
> On Thu, Jun 15, 2023 at 06:43:03PM +0300, Dan Carpenter wrote:
> > Do not call mutex_unlock(&gadget->udc->connect_lock) twice in a row.
> > 
> > Fixes: 286d9975a838 ("usb: gadget: udc: core: Prevent soft_connect_store() race")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> >  drivers/usb/gadget/udc/core.c | 2 --
> >  1 file changed, 2 deletions(-)
> > 
> > diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> > index 83fd1de14784..d58640a9d0ca 100644
> > --- a/drivers/usb/gadget/udc/core.c
> > +++ b/drivers/usb/gadget/udc/core.c
> > @@ -878,8 +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);
> >  	trace_usb_gadget_activate(gadget, ret);
> > -- 
> > 2.39.2
> > 
> 
> Does not apply to my tree :(

No longer required.  The patch was reverted.

regards,
dan carpenter
Greg KH June 19, 2023, 3:06 p.m. UTC | #4
On Mon, Jun 19, 2023 at 05:46:28PM +0300, Dan Carpenter wrote:
> On Mon, Jun 19, 2023 at 03:39:05PM +0200, Greg Kroah-Hartman wrote:
> > On Thu, Jun 15, 2023 at 06:43:03PM +0300, Dan Carpenter wrote:
> > > Do not call mutex_unlock(&gadget->udc->connect_lock) twice in a row.
> > > 
> > > Fixes: 286d9975a838 ("usb: gadget: udc: core: Prevent soft_connect_store() race")
> > > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > > ---
> > >  drivers/usb/gadget/udc/core.c | 2 --
> > >  1 file changed, 2 deletions(-)
> > > 
> > > diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> > > index 83fd1de14784..d58640a9d0ca 100644
> > > --- a/drivers/usb/gadget/udc/core.c
> > > +++ b/drivers/usb/gadget/udc/core.c
> > > @@ -878,8 +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);
> > >  	trace_usb_gadget_activate(gadget, ret);
> > > -- 
> > > 2.39.2
> > > 
> > 
> > Does not apply to my tree :(
> 
> No longer required.  The patch was reverted.

Ah good, thanks for checking.
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 83fd1de14784..d58640a9d0ca 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -878,8 +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);
 	trace_usb_gadget_activate(gadget, ret);