Article View: linux.kernel.netdev
Article #26330[PATCH v5 17/33] Input: gameport - use the compatibility driver attachment API
From: Leon Romanovsky
Date: Thu, 03 Dec 2026 12:03
Date: Thu, 03 Dec 2026 12:03
57 lines
10108 bytes
10108 bytes
From: Leon Romanovsky <leonro@nvidia.com>
Manual gameport binding calls the driver's connect callback without the
device lock, allowing it to race with generic sysfs probing. Normal
probing would run CONFIG_DEBUG_TEST_DRIVER_REMOVE under gameport_mutex;
a disconnect callback that unregisters a child port would then deadlock
trying to acquire the same mutex.
Use device_driver_attach_unrestricted() to centralize binding and failure
cleanup without the debug removal cycle. Take the device lock with
device_trylock() to serialize attachment with generic probing. Return
-EBUSY on contention because waiting while holding gameport_mutex could
deadlock with probe cleanup that needs it.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/input/gameport/gameport.c | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index 9707b155bc94..88b1a3464bf3 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -216,24 +216,12 @@ static int gameport_bind_driver(struct gameport *gameport, struct gameport_drive
{
int error;
- gameport->dev.driver = &drv->driver;
- if (drv->connect(gameport, drv)) {
- gameport->dev.driver = NULL;
- return -ENODEV;
- }
+ if (!device_trylock(&gameport->dev))
+ return -EBUSY;
- error = device_bind_driver(&gameport->dev);
- if (error) {
- dev_warn(&gameport->dev,
- "device_bind_driver() failed for %s (%s) and %s, error: %d\n",
- gameport->phys, gameport->name,
- drv->description, error);
- drv->disconnect(gameport);
- gameport->dev.driver = NULL;
- return error;
- }
-
- return 0;
+ error = device_driver_attach_unrestricted(&drv->driver, &gameport->dev);
+ device_unlock(&gameport->dev);
+ return error;
}
static void gameport_find_driver(struct gameport *gameport)
--
2.56.1
Technical Details
Message-ID:
<20261203-device-trust-core-v5-17-485cc6eddd46@nvidia.com>Path:
mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!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-376551-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!srl.newsdeef.eu.MISMATCH!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-376551-linux-kernel-netdev=dewy.ru From: leon@kernel.org (Leon Romanovsky) Newsgroups: linux.kernel.netdev Subject: [PATCH v5 17/33] Input: gameport - use the compatibility driver attachment API Date: Thu, 3 Dec 2026 14:03:39 +0200 Organization: Usenet Network Message-ID: <20261203-device-trust-core-v5-17-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="2480869"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:3ZRvnz/BbDfEx/PK/9DnjOJ4SGY= sha256:ILwBRrbGWNGmcNXH5NIW6BPWItJmcvytiHV7eC8uQLQ= sha1:hhw04nv7di7Wa5m2rjtgd6m4fpc= sha256:cq7nfaM921NRIVhP/TEvdXLwcfKPH5kxwzfAWHirpPA= 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 9C687117911; Thu, 3 Dec 2026 15:07:22 +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 xhfonepC2OIK; Thu, 3 Dec 2026 15:07:20 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-376551-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 4C2E4117904; Thu, 3 Dec 2026 15:07:12 +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 9535B25F69; Thu, 3 Dec 2026 12:07:09 +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=1796299499; b=ZFXGgaYFmWRyPr7SUzYh0KGXpxd61Ibi13OZbB4W4vW900dUAbzp9QMtvH8XIhKGzvkH 5AwZ1ngxEGxxFKX6TpAjDDA0FSvHxa5/3t1XFRbT8NkLZyS0b8tFIAzKRi+mN45P0Q4fp FzNdykOE3BED2pbl6ZKwlNtRmv+BYHS8me2WpRpwAUWPWO8jAJy7r/VuC5ZVdH8Y62KuV 2szFyR4vhWRcxsZWp+/O4XO9Wa5trsnsaicX6ImZ471gsQChRJNLz8NFAVA1jiHzqR8oM nYaNoULh68TvBQU7lSMcsiSHskLGffrgUWXBpjr0t0RQDcdw8fsVXuRaAhdKsHnJX3g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796299499; 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=cTMO5Y24NzwFSOhnTvKi0WkgdOMJGh9uGX3qwsFMkps=; b=2KQJQb3FK2iyDZeFYXb/J4OJXdtQSF2QTbTHEaRyUtieqK5arNudwAmG5k1dP+EQh6Kt BjmqncMVuFcQK2JoOvm/cCUZAeMhr4+ZKnyeAjR7BBdJqKZBJaB8MH/O0g4c6ujdtoRmD sMzUFNsd9rt6meC0IqpidRAalA7pHEHybmFDF3z8UiqDPnBYhP+QDFPrICmSPeMLoWd80 FnYnQW3WI6XQ7Hx+EGDtpFi4Co3qnvrYGpaJDX9iDAWb/fuWe3kU5lCsfIBMB+FqTtwIV hS8T9DqI4o32+8WujIqU3M27BaHx3KcECrm83Mh0rDfgYy0lX8sCzA/Nmww/oaGwC/A== 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=kytDZG8i; 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 47174606A330; Thu, 3 Dec 2026 12:04:59 +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=kytDZG8i 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=1796299493; b=pk879I8rgAgtYJvk4Ijj/KKnN8mIBIdEvPBnSbLDknowaPWpDFan7MY4rXcITgTi5CJI 4Qzjm+yyH9LdsXW2rEx3PBEUQE2NqEUFo7ml0GhAqX8TuntH2c8gS1D5gDFi+EMKj4x26 gurrVjheycWwdp4bY/H6Hwz6GGpjAe2iG5yJL6YcvKnIgvjP6Nzcs+2MW3iYabCxefj+p O5tmmr9TC2LWw8zTZ5WgGdRqsRx3XAxUb812N3JeHvYJt+mxoIhThuIWGGpLYqGkuMFMH sV60ZSvdbFwpBncgTsI5LTxZ13FNOsIS4beOpgg+L3YKwdytASJquS6dn7VOAV7PsZw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796299493; 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=cTMO5Y24NzwFSOhnTvKi0WkgdOMJGh9uGX3qwsFMkps=; b=Phsn5wTXzMKyMm5avqWCGzPgCkVbVJhHr6jOdaCuNP89CImVqhxNZnxSw1HXZwDaOFeX aDWV0AqyVf3Je09zLvXldB/s9uFvjwW29H06NyoHPa5AHCd5KMqYZLndt56yzfFPiGlsg ZgsnahDU72vOEdji3bFtiVUtYsmJTxLtEEd+YAZE7hgoOzXsRYWm0g1HgsMLn3llj7E0W v5HOkgWemKzMMKNlQF47dEv1cz4/DzZV2RuBzg/FxS9tCIZPlrYN4YbrYxH7bSwPG5ody SClJ8iK5DC0mmdFEBE9wJB4bhdBf1m9ZhGmaHlVqRR4QgPYFEw5xwkqVIq1dwAD5YBQ== 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=kytDZG8i; 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 60679606E755; Thu, 3 Dec 2026 12:04:53 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7428E1F00893; Thu, 3 Dec 2026 12:04:52 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796299493; bh=cTMO5Y24NzwFSOhnTvKi0WkgdOMJGh9uGX3qwsFMkps=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kytDZG8is0cVoSvmRhFKnvv81mfnnvXGmMAEsxKIhublsWlHnRK/U6pG8M1eyzCuE 5a0ha+dz/q1bmjoABlM1MMjho6rDph8ScgC+xqSVWZU/jKASf8L/jm6X5e8AKz85xQ wXIysN+LsIACwkGAAKkstyxEOHx58QHVi9nJFXRKZdAKctHeW+P6IZ7De+KmRQcYYO kX2AbgkmDBAVD0gtUZUafWZ5Z1S4rRjBc9Rgeqo80bTXZRSccmvLn4BjYiPtN+wI4d c42IOwz3/bWlhuZTHbNupQOc4V0ZIUiTcXMs0eilszAYz1gF9Gpn3hML0NTIhuES8n x9BYLOjRruh1A== 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