🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #18708

[PATCH v3 12/31] PNP: Attach card devices through the driver core

#18708
From: Leon Romanovsky
Date: Wed, 18 Nov 2026 19:26
64 lines
10111 bytes
From: Leon Romanovsky <leonro@nvidia.com>

pnp_request_card_device() calls the PnP bus probe directly, bypassing
the driver core's supplier checks and power management setup. If
device_bind_driver() then fails to create the sysfs links, the device
remains attached and may stay active, but the caller receives NULL and
cannot release it.

Use device_driver_attach() for synchronous probing with the driver
core's setup and error handling. Preserve the card link until binding
completes, so probe cleanup and CONFIG_DEBUG_TEST_DRIVER_REMOVE cannot
clear or free a link still owned by the enclosing card probe.

Fixes: bfc7ee207078 ("[PATCH] PNP: handle sysfs errors")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/pnp/card.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index df5e3d3cbf6c0..9aaaa03d5ffa9 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -52,13 +52,17 @@ static const struct pnp_card_device_id *match_card(struct pnp_card_driver *drv,
 
 static void card_remove(struct pnp_dev *dev)
 {
-	dev->card_link = NULL;
+	if (device_is_bound(&dev->dev))
+		dev->card_link = NULL;
 }
 
 static void card_remove_first(struct pnp_dev *dev)
 {
 	struct pnp_card_driver *drv = to_pnp_card_driver(dev->driver);
 
+	/* The card probe still owns its link until this device is bound. */
+	if (!device_is_bound(&dev->dev))
+		return;
 	if (!dev->card || !drv)
 		return;
 	if (drv->remove)
@@ -331,16 +335,12 @@ struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
 
 found:
 	dev->card_link = clink;
-	dev->dev.driver = &drv->link.driver;
-	if (pnp_bus_type.probe(&dev->dev))
-		goto err_out;
-	if (device_bind_driver(&dev->dev))
+	if (device_driver_attach(&drv->link.driver, &dev->dev))
 		goto err_out;
 
 	return dev;
 
 err_out:
-	dev->dev.driver = NULL;
 	dev->card_link = NULL;
 	return NULL;
 }

-- 
2.56.1
Technical Details
Message-ID: <20261118-device-trust-core-v3-12-d655875c4bfb@nvidia.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366384-linux-kernel-netdev=dewy.ru
References: <20261118-device-trust-core-v3-0-d655875c4bfb@nvidia.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366384-linux-kernel-netdev=dewy.ru
From: leon@kernel.org (Leon Romanovsky)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v3 12/31] PNP: Attach card devices through the driver core
Date: Wed, 18 Nov 2026 21:26:42 +0200
Organization: Usenet Network
Message-ID: <20261118-device-trust-core-v3-12-d655875c4bfb@nvidia.com>
References: <20261118-device-trust-core-v3-0-d655875c4bfb@nvidia.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2681118"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:LZ4/VcZcLf4C8XVg7XDcBTHNPGo= sha256:DTJQn0aBvg7yoHVIozgfPoyHhG+wU28o+SYzDxWUZpI=
	sha1:BvtIQfJVeF004xtZdDleWdBEAnM= sha256:xmR92MAKmuSpVnZVDFTKt6BwKOX3W4hdiZqtdiH40mo=
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 17888115394; Wed, 18 Nov 2026 22:31:04 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.301
X-Spam-Status: No, score=-2.301 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001,
	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 gBxo-Zjq1a7G;
	Wed, 18 Nov 2026 22:31:00 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-366384-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 6DCF8115385; Wed, 18 Nov 2026 22:30:50 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 7CF101285F1; Wed, 18 Nov 2026 19:29:55 +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=1795030088;
	b=vnXOY/lgqgH8rSOtxtAvrBSGBJ72VQrQ/XnXyE95x7mIhCg2mbc7UU26OzKW0vKil23f
	 HpZPFWLd7fBmRDa5zdmhdmDFaBI1vxMK65yzaMpn9N3GAwTAmMxaGf/bZbWrEZF27dzPv
	 hVEtxswBOxibcwTRLPDYHY8kCZmPfYpPf4PKJCZI0DUUBmGvmzf3UoxRNSCFWGtDwEbPz
	 bcgT2TAmLIBoPGHn3f5q7rFo1wKzQY2DcKmPuPnExgvUV9u3YchJ+Q3pbC2NGXJhezdxx
	 2gVoZtSD1ns18MQK9qsiGTB7EdA2uErSEPxSEx89dPx3irkiHq/ZG0XVkGX9IUGGQew==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795030088;
	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=YIoF29/HLGxivKo9y9Umvo7WdoqaNvqRS3anqksW2+E=;
	b=34ccEWGXQM1Cu3pQRFxk2aiIO3DbKpomr3A2B+3JngiIg8kn8I4ROOKzNbiv+q678A1g
	 LltG5TDlWWpZIp0DxvZ4s702lNT3myQBvvDj8ogOgKdxNhHxZphFyugWWILnJL+oM0wcO
	 OJoKiGU+G4Xm60oG7v3HHFLaECykxnoI/Yv7VGQxdcShBT+nQN66brV5vEm73T9Bdivpj
	 vxvzzj7iCdBV2HAIafU8GGKsvd+sTRqo/mRLh4i8e9rJxY+BnkW9X6QueZQxOrgpcgwef
	 xScQKsTZbUyUZxtlmDgh7zTF3MNHGt2+YuQWTdaTgG3HMuaqU9hW8V/2PpUR9+01caQ==
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=GRZV72CP;
	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 1696D606DD00;
	Wed, 18 Nov 2026 19:28:08 +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=GRZV72CP
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=1795030082;
	b=vg9jpTUuGLP9BFou0Dni1r7OETSzUak/4tmUQbdyRHHbXrLqgD1Sulc85oJQXECGcjWU
	 l1ppExuM6uNKKvkuH8AUM3mjj9btA3nmfRKkhCtPWKpELOTJKAEmPfomE1sP5EX5CHWwi
	 UiiPGjv73VQJ1dV6IPLDTfRVs73qNHHOHl/ifc5WoJ3PxwXFhD+jaUlr2EIqB4tXWrBqN
	 IctNdZe3xN2Tytei1SYq9E7pWeDLnG8L+0cVgZIkGJbVncBhQ5Z3I3Fwf04cOOsyl7tO1
	 6/qvpXxFYJJAGtjw6g6NNPmaK9mk80zXsEIWs8IWYC++mEuOnis1fKl/dvZCSGhGlRg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795030082;
	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=YIoF29/HLGxivKo9y9Umvo7WdoqaNvqRS3anqksW2+E=;
	b=zotAHFrzw+FPfxQFGbfzyZHPaXJVIVLpLPN1TkdXHf4CsuAt2ije5m9FeTasOea6TpXm
	 yQGtTjkh/tKZGlJHmoS3AnLWaCmpPPLdVesZspynOzDhdg7QxjXCfu0vuHKsTofeWpYMD
	 pGiSCjuC49IRhPwbToxPbotgD8FWC+3zaGzJuvVEXv5SdT558I9+qCjtOHJMHHFjeHDmy
	 Ykv/yfIguuhyll0XHln1NVJItQMXflC5ANwa+TCPoyrwXDLfLQLEFPK815uNAYHb08mwC
	 gkS5F5IPtD33+Zr0COHareh/Y//LApXMTa8xPE49/kMRMm0k7SiKllmoBDfAKUR4i+g==
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=GRZV72CP;
	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 30CEC606A7E4;
	Wed, 18 Nov 2026 19:28:01 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBEA81F000CD;
	Wed, 18 Nov 2026 19:28:00 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795030081;
	bh=YIoF29/HLGxivKo9y9Umvo7WdoqaNvqRS3anqksW2+E=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=GRZV72CPjqMFDz8QVvFaDzm4LVKAGO1cB/qlcrZnlS+aSNN6dyhiAHzc7/Iuazi1G
	 E0+HoqJ35Lv7sBXo/FIcUJd2exYCi2hqwuURJZBJBZldug/vwUmFY3kO+fAcQ4wg+q
	 /j0H4tydBClBdMwpvshpct6bF3mbB2fVgJbBRIXWSFAEL1kw+U1Fjoohcmu1dgOk0w
	 mk5tarzoqyQbkocZUsOikIW25i//qizQMtr19cD/8MJiauMsTWUJQFr9y7yKWVNyiz
	 t259FRj7GvUVWH/K2dML1UyuCkdGAgufckIztJb7hXSUUALe+sxnopyvIi1cbG5YQr
	 jJhaay2TAN8kg==
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: <20261118-device-trust-core-v3-0-d655875c4bfb@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.15-dev-18f8f