From: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
To: Daniel Walker <dwalker@mvista.com>
Cc: gregkh@suse.de, linux-usb-users@lists.sourceforge.net,
linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
mingo@elte.hu
Subject: Re: [PATCH] USB testing driver: convert dev->sem to mutex
Date: Tue, 4 Dec 2007 23:31:51 +0100 [thread overview]
Message-ID: <20071204223151.GB480@traven> (raw)
In-Reply-To: <1196795342.1568.41.camel@jnielson-xp.ddns.mvista.com>
El Tue, Dec 04, 2007 at 11:09:02AM -0800 Daniel Walker ha dit:
> On Tue, 2007-12-04 at 17:55 +0100, Matthias Kaehlcke wrote:
> > @@ -1990,7 +1991,7 @@ static void usbtest_disconnect (struct
> > usb_interface *intf)
> > {
> > struct usbtest_dev *dev = usb_get_intfdata (intf);
> >
> > - down (&dev->sem);
> > + mutex_lock(&dev->lock);
> >
> > usb_set_intfdata (intf, NULL);
> > dev_dbg (&intf->dev, "disconnect\n");
>
> This looks like a bit of an anomaly.. The code that isn't shown above is
> the "kfree(dev)" .. So this isn't legal since it's freeing a locked
> mutex. Here's a excerpt from the comment above mutex_lock(),
>
> * The mutex must later on be released by the same task that
> * acquired it. Recursive locking is not allowed. The task
> * may not exit without first unlocking the mutex. Also, kernel
> * memory where the mutex resides mutex must not be freed with
> * the mutex still locked. The mutex must first be initialized
> * (or statically defined) before it can be locked. memset()-ing
> * the mutex to 0 is not allowed.
you're absolutely right that freeing a locked mutex isn't a good idea
thanks for pointing it out!
--
Matthias Kaehlcke
Linux System Developer
Barcelona
Don't walk behind me, I may not lead
Don't walk in front of me, I may not follow
Just walk beside me and be my friend
(Albert Camus)
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-
prev parent reply other threads:[~2007-12-04 22:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-04 16:55 [PATCH] USB testing driver: convert dev->sem to mutex Matthias Kaehlcke
2007-12-04 19:09 ` Daniel Walker
2007-12-04 22:31 ` Matthias Kaehlcke [this message]
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=20071204223151.GB480@traven \
--to=matthias.kaehlcke@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dwalker@mvista.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb-users@lists.sourceforge.net \
--cc=mingo@elte.hu \
/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