[patch]fix autosuspend race in skeleton driver

Oliver Neukum <[email protected]>
Newsgroups gmane.linux.usb.devel
Organization Novell
Message-ID <[email protected]>
Hi,

as the skeleton driver was made ready for autosuspend a race condition
was introduced. The reference to get device must be gotten before the
autosuspend counter is upped, as this operation may sleep, dropping BKL.
Dropping BKL means that the pointer to the device may become invalid.
Here's the fix.

	Regards
		Oliver

Signed-off-by: Oliver Neukum <[email protected]>
----

--- a/drivers/usb/usb-skeleton.c	2007-02-08 15:32:17.000000000 +0100
+++ b/drivers/usb/usb-skeleton.c	2007-02-08 15:33:19.000000000 +0100
@@ -90,13 +90,15 @@
 		goto exit;
 	}
 
+	/* increment our usage count for the device */
+	kref_get(&dev->kref);
+
 	/* prevent the device from being autosuspended */
 	retval = usb_autopm_get_interface(interface);
-	if (retval)
+	if (retval) {
+		kref_put(&dev->kref, skel_delete);
 		goto exit;
-
-	/* increment our usage count for the device */
-	kref_get(&dev->kref);
+	}
 
 	/* save our object in the file's private structure */
 	file->private_data = dev;

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.