aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/misc
diff options
context:
space:
mode:
authorOliver Neukum <oliver@neukum.org>2007-10-28 08:21:59 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2007-11-28 13:58:33 -0800
commited206ec9ab398e1c3756ff0eb9507db1d009e65f (patch)
treed13e50319c8a0f870ffe04b561e7688ea44deb1a /drivers/usb/misc
parent7ced46c3ad1dfaaabf9ec6c98cbb0a48e080fb11 (diff)
USB: fix usbled disconnect read race #2
usbled has a race where show methods for attributes in sysfs can follow a NULL pointer during disconnect. The correct ordering fixes it. Signed-off-by: Oliver Neukum <oneukum@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r--drivers/usb/misc/usbled.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c
index 49c5c5c4c43..06cb71942dc 100644
--- a/drivers/usb/misc/usbled.c
+++ b/drivers/usb/misc/usbled.c
@@ -144,12 +144,14 @@ static void led_disconnect(struct usb_interface *interface)
struct usb_led *dev;
dev = usb_get_intfdata (interface);
- usb_set_intfdata (interface, NULL);
device_remove_file(&interface->dev, &dev_attr_blue);
device_remove_file(&interface->dev, &dev_attr_red);
device_remove_file(&interface->dev, &dev_attr_green);
+ /* first remove the files, then set the pointer to NULL */
+ usb_set_intfdata (interface, NULL);
+
usb_put_dev(dev->udev);
kfree(dev);