From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, usb4-upstream@oss.qualcomm.com
Subject: Re: [PATCH] usb: dwc3: gadget: destroy connect_mutex after usb_del_gadget
Date: Thu, 26 Nov 2026 09:38:14 +0100 [thread overview]
Message-ID: <eafaa164-50d5-4d64-80d2-468dcff3d184@oss.qualcomm.com> (raw)
In-Reply-To: <20261123-topic-dwc3_gadget_fix-v1-1-dec7679b81b7@oss.qualcomm.com>
On 11/23/26 9:13 PM, Konrad Dybcio wrote:
> usb_del_gadget() unbinds the function driver, which may still call
> dwc3_gadget_pullup() and take connect_mutex. Destroying the mutex
> before that point leaves a live lock behind during teardown.
>
> Avoid it.
>
> Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> ---
> drivers/usb/dwc3/gadget.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index a76f669a796c2e0eb955969a88523affcb672ae2..673f4bffb8ca85778d084820ecfed49f50d1cac3 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -5027,9 +5027,9 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
> return;
>
> cancel_work_sync(&dwc->err_recovery_work);
> - mutex_destroy(&dwc->connect_mutex);
> dwc3_enable_susphy(dwc, true);
> usb_del_gadget(dwc->gadget);
> + mutex_destroy(&dwc->connect_mutex);
> dwc3_gadget_free_endpoints(dwc);
> usb_put_gadget(dwc->gadget);
> dma_free_coherent(dwc->sysdev, DWC3_BOUNCE_SIZE, dwc->bounce,
Looks like Marek's patch (in next now) fixed the same issue,
ignore this one
https://lore.kernel.org/linux-usb/73cbf05a-e25d-46de-b956-504086660570@samsung.com/
Konrad
prev parent reply other threads:[~2026-11-26 8:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 20:13 [PATCH] usb: dwc3: gadget: destroy connect_mutex after usb_del_gadget Konrad Dybcio
2026-11-23 20:30 ` sashiko-bot
2026-11-26 8:38 ` Konrad Dybcio [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=eafaa164-50d5-4d64-80d2-468dcff3d184@oss.qualcomm.com \
--to=konrad.dybcio@oss.qualcomm.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=usb4-upstream@oss.qualcomm.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