Article View: linux.kernel.netdev
Article #26322[PATCH v5 12/33] USB: Unwind interface claims after registration or binding failure
From: Leon Romanovsky
Date: Thu, 03 Dec 2026 12:03
Date: Thu, 03 Dec 2026 12:03
114 lines
12156 bytes
12156 bytes
From: Leon Romanovsky <leonro@nvidia.com>
A successful USB-audio control probe can claim unregistered playback and
capture interfaces. If playback registration fails, releasing its claim
alone leaves the card active, its disconnect callback returns immediately.
usb_set_configuration()
device_add(control)
usb_audio_probe()
snd_usb_create_streams()
snd_usb_create_stream(playback)
usb_driver_claim_interface(playback)
snd_usb_create_stream(capture)
usb_driver_claim_interface(capture)
device_add(playback) [fails]
Configuration removal skips unregistered claims. Binding failure can
clear dev->driver without disconnecting the claimant, and disabled
autoprobe leaves the claim unbound.
Release every claim that driver core left unbound, remove the
configuration if sibling claims remain, and disconnect unpublished
claims before freeing interfaces or dropping the module reference. A
bound claim is on the driver's device list, so unload waits for its
disconnect.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Fixes: 86d30741e480f ("[PATCH] USB: Usbcore: Don't try to delete unregistered interfaces")
Fixes: c6a46696f97ff ("driver core: don't fail attaching the device if it cannot be bound")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/usb/core/message.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index cfb4cbdbe76f..e7a23e406f8a 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1489,6 +1489,9 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
device_del(&interface->dev);
}
+ for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++)
+ usb_release_unregistered_interface(dev->actconfig->interface[i]);
+
/* Now that the interfaces are unbound, nobody should
* try to access them.
*/
@@ -2020,6 +2023,25 @@ int usb_set_wireless_status(struct usb_interface *iface,
}
EXPORT_SYMBOL_GPL(usb_set_wireless_status);
+static bool usb_has_claimant(struct usb_device *dev,
+ const struct device_driver *claimant)
+{
+ struct usb_host_config *config = dev->actconfig;
+ int i;
+
+ for (i = 0; i < config->desc.bNumInterfaces; i++) {
+ struct device *intf = &config->interface[i]->dev;
+ bool claimed;
+
+ device_lock(intf);
+ claimed = intf->driver == claimant;
+ device_unlock(intf);
+ if (claimed)
+ return true;
+ }
+ return false;
+}
+
/*
* usb_set_configuration - Makes a particular device setting be current
* @dev: the device whose configuration is being updated
@@ -2270,6 +2292,7 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
*/
for (i = 0; i < nintf; ++i) {
struct usb_interface *intf = cp->interface[i];
+ struct device_driver *claimant;
struct module *claim_owner;
if (intf->dev.of_node &&
@@ -2285,10 +2308,26 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
intf->cur_altsetting->desc.bInterfaceNumber);
device_enable_async_suspend(&intf->dev);
device_lock(&intf->dev);
+ claimant = intf->dev.driver;
claim_owner = xchg(&intf->claim_owner, NULL);
device_unlock(&intf->dev);
ret = device_add(&intf->dev);
- module_put(claim_owner);
+ if (claimant &&
+ usb_driver_release_refused_claim(intf, claimant)) {
+ bool unconfigure = usb_has_claimant(dev, claimant);
+
+ get_device(&intf->dev);
+ if (unconfigure)
+ usb_set_configuration(dev, -1);
+ module_put(claim_owner);
+ put_device(&intf->dev);
+ if (unconfigure) {
+ usb_autosuspend_device(dev);
+ return ret ? ret : -ENODEV;
+ }
+ } else {
+ module_put(claim_owner);
+ }
if (ret != 0) {
device_lock(&intf->dev);
intf->unregistering = 1;
--
2.56.1
Technical Details
Message-ID:
<20261203-device-trust-core-v5-12-485cc6eddd46@nvidia.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376546-linux-kernel-netdev=dewy.ruReferences:
<20261203-device-trust-core-v5-0-485cc6eddd46@nvidia.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376546-linux-kernel-netdev=dewy.ru From: leon@kernel.org (Leon Romanovsky) Newsgroups: linux.kernel.netdev Subject: [PATCH v5 12/33] USB: Unwind interface claims after registration or binding failure Date: Thu, 3 Dec 2026 14:03:34 +0200 Organization: Usenet Network Message-ID: <20261203-device-trust-core-v5-12-485cc6eddd46@nvidia.com> References: <20261203-device-trust-core-v5-0-485cc6eddd46@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2480170"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:4G3epbs72B2xyAtMsOYyUcs68hw= sha256:XSfExt+iwQIzTQgULuiLqcyyuY+pO3sKH/VVtXYgABw= sha1:cTSPPfosqPDsT8eGHYUnvcBHj2Y= sha256:HEAcFgOD8jpbPfzZ7b83v/0pVoxZeb3cUFEji1ptWF0= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id E440511790B; Thu, 3 Dec 2026 15:06:13 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.64 X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oqDyvITzuayo; Thu, 3 Dec 2026 15:06:11 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-376546-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 6530F1178D0; Thu, 3 Dec 2026 15:06:03 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 81A7A26ECB; Thu, 3 Dec 2026 12:06:01 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796299483; b=BGabX0HhBclu669M487s83riAP0sBU7Y0FQLBnrQ2XAYJbOWmXI0qR6oo+YZoTnKJcj4 nTRqHnHMOOg9+AGX07D0qd7QKBia1nPlY8EcsDxbThlq0/kWE/vLun3ZnI8zmmA0QjZ9X c7KkNRQCWammGsvESBSjEcxsCkNymBbnRftVLB8Yzz2X4oB5AyoQuRci7NZKa44JA2Oiw IDLLb06hgaFUcbNSXiTcqhsZndhNuPpuKBqY8dMj3gCu6hyC9u20P5EWehI2/gka71kj9 bS2MhDraEDErPb7nQyAOUp16cMFxHDgk+gAOlfaLpZMVFXHmD5ANP0FW+tf1MA06S5w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796299483; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Type:X-Mailer: Content-Transfer-Encoding; bh=GX3k/yvLLpPBUvCdBQg7fAxkT9P4BE3TrARoKLvsmNk=; b=AGfUY4dmT1+1p0tWsjOX5jaEYMu9O0WcYj4rXrNw7OUyNoW30mJhwlA0Yqtcp/ifJoD2 s1i1UcS8Hj2vFfZqhThh8R0zVxsuoRVLP4FJrkA5RFP7jDcer3n3FAf4zPZH31ypKGDF3 tdKGUHnPLJm63UoEr2VywB7odQDtuDCam/9JlCrxvOBcp8J/lInFDMxzvMTiqENwmyPYs VGGa7dNKJZwWMtecVoZjqNdfNr0e+RtBHqrcKl8Z4sQqMOjRvDCoRR76A2H4gTeARlfrt HV4VWo3i1H7N9XsGR3PZkkR5mrh9lwmC8ktoj0rIHGZQVGieNCniqhTYqURpHAAjt5A== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=X4wOeVGr; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B6338606D147; Thu, 3 Dec 2026 12:04:43 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=X4wOeVGr X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796299477; b=5gUq/fLOpscbbDmc5HC0ilhj1/8WpIY2n/bRmnmA9H0B001VQrA09Mit3lpLQkbkciDY /ARbapSM3Jle0PJikWoQkELxvvEVzFB/f7JKPwWMKCPxiiYTosrOQprTeg5cg7vRkNTCw dg3E1B5LFj46gkyN5lwtQljTLUxLYWWfrZv9HInG9mw8s/W5jqpGBlfGq4xGfl+fvChiS yX/R0fIehy3HV0i4D20SXxjeN3Ok1YcCtv+hOQ3Y+qcSX/WPbxnrTSWrtkG0/WN9wkh6P 8ZPj6vIqdqZE7Epe0x3BVYFlfx+UxtkJYElv3c7yMc3lFlXo7gqzlBgzjYt/Vj3EXng== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796299477; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type:X-Mailer: Content-Transfer-Encoding; bh=GX3k/yvLLpPBUvCdBQg7fAxkT9P4BE3TrARoKLvsmNk=; b=fqiBX/6G4xd729BLQ2N6/+0QKwMMnBInyNoZLz/f2TpLBzpSYNUvFyP6SuAlWco7NKnD 9TIZ7gCN2e3UX82GWdm4asgl1JRUFqtqY5mpGt+528whbttqcjumSPsh9YxaJb7cfVACK EJwjXAINOalxO1VhHBfE8S1bS2hjLdiPGNlr6DyxJEKp+sztXdQFjbilSN3Oot5e+pDT8 dJmjm6Yo/UoBh2tpRULPEghLZ5i0KcDWp/yU6l/0EtxgIP/th9RveY7exmBpDoBfkqbR9 17k7A+mQTnU97Kh/yFI+4N2DMOcayoedLWb0cbth63Lw4ZJbxxC/QuvJxt/cuTjDjqQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=X4wOeVGr; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D176B606B1D3; Thu, 3 Dec 2026 12:04:37 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E70131F00926; Thu, 3 Dec 2026 12:04:36 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796299477; bh=GX3k/yvLLpPBUvCdBQg7fAxkT9P4BE3TrARoKLvsmNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=X4wOeVGrJfxIDfZt/9wn9INz1Bzv8YHPYWJlZ4AMwCWnoCJ4Y7wtoAMPSNhlPG1PF FdcGc3tYc58lm2ruXGsDQ9oBZYwLYQ0MQPnhWPEn5DlA2yv6pIp6YDmkeboE7eYlcW YHWZZecyFs4KxSiJmm0Tb0ITNfRL3AuusLpCHmnrodlTGqTpC3VX3EStiryv7e29V6 o5f1P8eopPsjSj/miH21j5ALlJxUQeEXRSgOC3ZySyIBPbz5RvdEMJZazbTpWxhj1o VEJZQyYRzgl97zXLQTBgLPtxMSUV+XtDhBG8IRV7sBFXI8rOhTtDEKI6TRKSp3K1Xr ICzMm/SPOVphw== X-Cc: linux-kernel@vger.kernel.org, driver-core@lists.linux.dev, linux-input@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-usb@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-acpi@vger.kernel.org, linux-doc@vger.kernel.org, linux-pci@vger.kernel.org, iommu@lists.linux.dev, linux-coco@lists.linux.dev, Alexey Kardashevskiy <aik@amd.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Greg Kroah-Hartman <gregkh@suse.de>, linux-sound@vger.kernel.org, Jason Gunthorpe <jgg@ziepe.ca> X-Mailer: git-send-email 2.56.1 X-In-Reply-To: <20261203-device-trust-core-v5-0-485cc6eddd46@nvidia.com> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-Mailer: b4 0.17-dev-d2b70