]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usb: gadget: core: flush gadget workqueue after device removal
authorRoy Luo <royluo@google.com>
Tue, 4 Feb 2025 23:36:42 +0000 (23:36 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Feb 2025 13:01:32 +0000 (14:01 +0100)
commitf894448f3904d7ad66fecef8f01fe0172629e091
treea78800c91546f5ff72f8fcc0743234e2e92f7b26
parenta5b205ceefa5e4d62c63f50fa4ee923ce66fdba2
usb: gadget: core: flush gadget workqueue after device removal

commit 399a45e5237ca14037120b1b895bd38a3b4492ea 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: 5702f75375aa9 ("usb: gadget: udc-core: move sysfs_notify() to a workqueue")
Cc: stable <stable@kernel.org>
Signed-off-by: Roy Luo <royluo@google.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Reviewed-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/20250204233642.666991-1-royluo@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/udc/core.c