mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "'Robert Baldyga'" <r.baldyga@samsung.com>,
	"balbi@ti.com" <balbi@ti.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"m.szyprowski@samsung.com" <m.szyprowski@samsung.com>,
	"andrzej.p@samsung.com" <andrzej.p@samsung.com>
Subject: RE: [PATCH] usb: gadget: composite: unlock spinlock before usb_gadget_disconnect()
Date: Fri, 13 Jun 2014 11:36:24 +0000	[thread overview]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1725C37A@AcuExch.aculab.com> (raw)
In-Reply-To: <1402658893-4809-1-git-send-email-r.baldyga@samsung.com>

From: Robert Baldyga
> usb_gadget_disconnect() shouldn't be called under spinlock to avoid
> spinlock recursion. Function usb_gadget_disconnect() calls pullup(),
> which is callback from UDC driver, usually calling composite_disconnect().
> This function wants to lock spinlock used in usb_function_deactivate()
> causing spinlock recursion.
...
> +++ b/drivers/usb/gadget/composite.c
> @@ -260,8 +260,11 @@ int usb_function_deactivate(struct usb_function *function)
> 
>  	spin_lock_irqsave(&cdev->lock, flags);
> 
> -	if (cdev->deactivations == 0)
> +	if (cdev->deactivations == 0) {
> +		spin_unlock_irqrestore(&cdev->lock, flags);
>  		status = usb_gadget_disconnect(cdev->gadget);
> +		spin_lock_irqsave(&cdev->lock, flags);
> +	}
>  	if (status == 0)
>  		cdev->deactivations++;

That sort of change rings big alarm bells.
You've effectively isolated the usb_gadget_disconnect() call
from the check that cdev->deactivations == 0.
And then you increment cdev->deactivations below.

Looks like it will be racy to me.

	David




  reply	other threads:[~2014-06-13 11:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-13 11:28 Robert Baldyga
2014-06-13 11:36 ` David Laight [this message]
2014-06-19 13:48   ` Felipe Balbi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=063D6719AE5E284EB5DD2968C1650D6D1725C37A@AcuExch.aculab.com \
    --to=david.laight@aculab.com \
    --cc=andrzej.p@samsung.com \
    --cc=balbi@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=r.baldyga@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®