public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Roy Luo <royluo@google.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"andre.draszik@linaro.org" <andre.draszik@linaro.org>,
	"elder@kernel.org" <elder@kernel.org>,
	"stern@rowland.harvard.edu" <stern@rowland.harvard.edu>,
	"crwulff@gmail.com" <crwulff@gmail.com>,
	"paul@crapouillou.net" <paul@crapouillou.net>,
	"jkeeping@inmusicbrands.com" <jkeeping@inmusicbrands.com>,
	"yuanlinyu@hihonor.com" <yuanlinyu@hihonor.com>,
	"sumit.garg@linaro.org" <sumit.garg@linaro.org>,
	"balbi@ti.com" <balbi@ti.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v2] usb: gadget: core: flush gadget workqueue after device removal
Date: Wed, 12 Feb 2025 01:17:53 +0000	[thread overview]
Message-ID: <20250212011750.h6epao5gs25ibdvb@synopsys.com> (raw)
In-Reply-To: <20250204233642.666991-1-royluo@google.com>

On Tue, Feb 04, 2025, Roy Luo wrote:
> 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@vger.kernel.org>
> Signed-off-by: Roy Luo <royluo@google.com>
> ---
>  drivers/usb/gadget/udc/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> index a6f46364be65..4b3d5075621a 100644
> --- a/drivers/usb/gadget/udc/core.c
> +++ b/drivers/usb/gadget/udc/core.c
> @@ -1543,8 +1543,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);
> 
> base-commit: f286757b644c226b6b31779da95a4fa7ab245ef5
> -- 
> 2.48.1.362.g079036d154-goog
> 

Reviewed-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

Thanks,
Thinh

      parent reply	other threads:[~2025-02-12  1:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04 23:36 [PATCH v2] usb: gadget: core: flush gadget workqueue after device removal Roy Luo
2025-02-05 16:44 ` Alan Stern
2025-02-12  1:17 ` Thinh Nguyen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250212011750.h6epao5gs25ibdvb@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=andre.draszik@linaro.org \
    --cc=balbi@ti.com \
    --cc=crwulff@gmail.com \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jkeeping@inmusicbrands.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=paul@crapouillou.net \
    --cc=royluo@google.com \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=sumit.garg@linaro.org \
    --cc=yuanlinyu@hihonor.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox