Skip to content

Commit

Permalink
USB: fix read vs. disconnect race in cytherm driver
Browse files Browse the repository at this point in the history
the disconnect method of this driver set intfdata to NULL before
removing attribute files. The attributes' read methods will happily
follow the NULL pointer. Here's the correct ordering.

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 Oct 25, 2007
1 parent 54d2bc0 commit d718d2b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/usb/misc/cytherm.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,16 @@ static void cytherm_disconnect(struct usb_interface *interface)
struct usb_cytherm *dev;

dev = usb_get_intfdata (interface);
usb_set_intfdata (interface, NULL);

device_remove_file(&interface->dev, &dev_attr_brightness);
device_remove_file(&interface->dev, &dev_attr_temp);
device_remove_file(&interface->dev, &dev_attr_button);
device_remove_file(&interface->dev, &dev_attr_port0);
device_remove_file(&interface->dev, &dev_attr_port1);

/* first remove the files, then NULL the pointer */
usb_set_intfdata (interface, NULL);

usb_put_dev(dev->udev);

kfree(dev);
Expand Down

0 comments on commit d718d2b

Please sign in to comment.