mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Walker <dwalker@mvista.com>
To: Matthias Kaehlcke <matthias.kaehlcke@gmail.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, 04 Dec 2007 11:09:02 -0800	[thread overview]
Message-ID: <1196795342.1568.41.camel@jnielson-xp.ddns.mvista.com> (raw)
In-Reply-To: <20071204165540.GH6729@traven>

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.

Daniel


  reply	other threads:[~2007-12-04 19:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-04 16:55 Matthias Kaehlcke
2007-12-04 19:09 ` Daniel Walker [this message]
2007-12-04 22:31   ` Matthias Kaehlcke

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=1196795342.1568.41.camel@jnielson-xp.ddns.mvista.com \
    --to=dwalker@mvista.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-users@lists.sourceforge.net \
    --cc=matthias.kaehlcke@gmail.com \
    --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

all inboxes | Powered by JetHome®