Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=5b06470816fb5e658e81db2a55b530ff2ba711c9
Commit:     5b06470816fb5e658e81db2a55b530ff2ba711c9
Parent:     57e4f041bfffa191a318dab44eb991d79a6a9d5c
Author:     Oliver Neukum <[EMAIL PROTECTED]>
AuthorDate: Thu Feb 8 15:42:53 2007 +0100
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Fri Feb 16 15:32:19 2007 -0800

    USB: fix autosuspend race in skeleton driver
    
    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.
    
    Signed-off-by: Oliver Neukum <[EMAIL PROTECTED]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
---
 drivers/usb/usb-skeleton.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 296b091..46929a1 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -90,13 +90,15 @@ static int skel_open(struct inode *inode, struct file *file)
                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;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to