From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22606234973 for ; Tue, 18 Feb 2025 11:44:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739879098; cv=none; b=GcMEDT5KH8U72G1PHoKpcCAqMd/G25RDIQaPvnDaSc6f+vULxTRgKh3lTKcl4+rT5+vLTgrIZ6cStcDnwe0TVoD3asjTtQhV/5HPGEG6iIu9md2xddTt4MLTbwHF1jn4mhVHbFjyTycOOieU00Xbpe9IpIST8V1Tl3n8sfhmdD8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739879098; c=relaxed/simple; bh=a0iL4vWwIXdmUwF7wLnyI9M0VlLTidrz/bxShp4Lve4=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=LearVSEv3+vhb+BVuBws2blxfye9T7Vu1UActNIc1rzbomZv5d184nw0eLleoiCDS952J7E1xJ5KDVp/Wtwg7dY5x6JoDMwSiQKkpJWyToB3422yCQwCmXmrnRSYUgs9McvDhN1vqY7xZ9jLmQMYoriRHRBQJa0ApvAyuCxK2Vs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nXriTwZb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nXriTwZb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40A17C4CEE6; Tue, 18 Feb 2025 11:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1739879097; bh=a0iL4vWwIXdmUwF7wLnyI9M0VlLTidrz/bxShp4Lve4=; h=Subject:To:Cc:From:Date:From; b=nXriTwZbMPMbkGWirlRB9gvRmR4Mu2tAYUtHtKz4ZYpYJdnUfoG1wBJSzyqSDld6B fTZPV0zkVpBAQjkp7ODTjrN7X7M/0ujsP4jroJBpEGESJ8PoV90NuMgFCPxqKvcpzk qwtCb/dZfjkZLsoIOYeZqRBM/sp7zjg223Rvsq2M= Subject: FAILED: patch "[PATCH] usb: gadget: core: flush gadget workqueue after device" failed to apply to 5.10-stable tree To: royluo@google.com,Thinh.Nguyen@synopsys.com,gregkh@linuxfoundation.org,stable@kernel.org,stern@rowland.harvard.edu Cc: From: Date: Tue, 18 Feb 2025 12:44:46 +0100 Message-ID: <2025021846-antihero-overall-1bfb@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x 399a45e5237ca14037120b1b895bd38a3b4492ea # git commit -s git send-email --to '' --in-reply-to '2025021846-antihero-overall-1bfb@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 399a45e5237ca14037120b1b895bd38a3b4492ea Mon Sep 17 00:00:00 2001 From: Roy Luo Date: Tue, 4 Feb 2025 23:36:42 +0000 Subject: [PATCH] usb: gadget: core: flush gadget workqueue after device removal 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 Signed-off-by: Roy Luo Reviewed-by: Alan Stern Reviewed-by: Thinh Nguyen Link: https://lore.kernel.org/r/20250204233642.666991-1-royluo@google.com Signed-off-by: Greg Kroah-Hartman 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);