diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c index 2677fea147d9..1cd9e7eba93b 100644 --- a/drivers/usb/misc/cytherm.c +++ b/drivers/usb/misc/cytherm.c @@ -399,7 +399,6 @@ 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); @@ -407,6 +406,9 @@ static void cytherm_disconnect(struct usb_interface *interface) 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);