Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ed206ec9 authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman
Browse files

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: default avatarOliver Neukum <oneukum@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7ced46c3
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -144,12 +144,14 @@ static void led_disconnect(struct usb_interface *interface)
	struct usb_led *dev;
	struct usb_led *dev;


	dev = usb_get_intfdata (interface);
	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_blue);
	device_remove_file(&interface->dev, &dev_attr_red);
	device_remove_file(&interface->dev, &dev_attr_red);
	device_remove_file(&interface->dev, &dev_attr_green);
	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);
	usb_put_dev(dev->udev);


	kfree(dev);
	kfree(dev);