Patch "usb: gadget: core: flush gadget workqueue after device removal" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    usb: gadget: core: flush gadget workqueue after device removal

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     usb-gadget-core-flush-gadget-workqueue-after-device-.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 21c317101fd7537c2d24930480ae0f575af4627d
Author: Roy Luo <royluo@xxxxxxxxxx>
Date:   Tue Feb 4 23:36:42 2025 +0000

    usb: gadget: core: flush gadget workqueue after device removal
    
    [ Upstream commit 399a45e5237ca14037120b1b895bd38a3b4492ea ]
    
    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@xxxxxxxxxx>
    Signed-off-by: Roy Luo <royluo@xxxxxxxxxx>
    Reviewed-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
    Reviewed-by: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20250204233642.666991-1-royluo@xxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 1d58adc597a7e..a4120a25428e5 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -1538,8 +1538,8 @@ void usb_del_gadget(struct usb_gadget *gadget)
 
 	kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE);
 	sysfs_remove_link(&udc->dev.kobj, "gadget");
-	flush_work(&gadget->work);
 	device_del(&gadget->dev);
+	flush_work(&gadget->work);
 	ida_free(&gadget_id_numbers, gadget->id_number);
 	cancel_work_sync(&udc->vbus_work);
 	device_unregister(&udc->dev);




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux