lkml.org 
[lkml]   [2007]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] USB testing driver: convert dev->sem to mutex
From
Date
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



\
 
 \ /
  Last update: 2007-12-04 20:23    [W:0.046 / U:0.604 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site