Skip to content

Commit

Permalink
USB: fix usbled disconnect read race #2
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Oliver Neukum authored and Greg Kroah-Hartman committed Nov 28, 2007
1 parent 7ced46c commit ed206ec
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/usb/misc/usbled.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ed206ec

Please sign in to comment.