Skip to content

Commit 4961fc3

Browse files
Roy Luomehmetb0
Roy Luo
authored andcommitted
usb: gadget: core: flush gadget workqueue after device removal
BugLink: https://bugs.launchpad.net/bugs/2104873 commit 399a45e upstream. device_del() can lead to new work being scheduled in gadget->work workqueue. This is observed, for example, with the dwc3 driver with the following call stack: device_del() gadget_unbind_driver() usb_gadget_disconnect_locked() dwc3_gadget_pullup() dwc3_gadget_soft_disconnect() usb_gadget_set_state() schedule_work(&gadget->work) Move flush_work() after device_del() to ensure the workqueue is cleaned up. Fixes: 5702f75 ("usb: gadget: udc-core: move sysfs_notify() to a workqueue") Cc: stable <[email protected]> Signed-off-by: Roy Luo <[email protected]> Reviewed-by: Alan Stern <[email protected]> Reviewed-by: Thinh Nguyen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Noah Wager <[email protected]> Signed-off-by: Mehmet Basaran <[email protected]>
1 parent 328987a commit 4961fc3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/usb/gadget/udc/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1543,8 +1543,8 @@ void usb_del_gadget(struct usb_gadget *gadget)
15431543

15441544
kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE);
15451545
sysfs_remove_link(&udc->dev.kobj, "gadget");
1546-
flush_work(&gadget->work);
15471546
device_del(&gadget->dev);
1547+
flush_work(&gadget->work);
15481548
ida_free(&gadget_id_numbers, gadget->id_number);
15491549
cancel_work_sync(&udc->vbus_work);
15501550
device_unregister(&udc->dev);

0 commit comments

Comments
 (0)