Netdev List
 help / color / mirror / Atom feed
* [PATCH] ice: Fix wrong dsn read in ice_adapter_put
@ 2026-05-13  9:09 Cyrill Gorcunov
  2026-05-17 12:53 ` Simon Horman
  0 siblings, 1 reply; 5+ messages in thread
From: Cyrill Gorcunov @ 2026-05-13  9:09 UTC (permalink / raw)
  To: LKML, NETDEV; +Cc: Tony Nguyen, Przemek Kitszel

When registering an adapter instance, we read the PCI configuration
space to fetch the DSN and generate an adapter index for lookups.

However, if the adapter has been physically unplugged, the PCI space
is no longer accessible. Reading it returns a zero value, which results
in either an incorrect adapter instance being put or the proper instance
not being put at all. To fix this, we will use the previously known
index instead.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 drivers/net/ethernet/intel/ice/ice_adapter.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux-tip.git/drivers/net/ethernet/intel/ice/ice_adapter.c
===================================================================
--- linux-tip.git.orig/drivers/net/ethernet/intel/ice/ice_adapter.c
+++ linux-tip.git/drivers/net/ethernet/intel/ice/ice_adapter.c
@@ -130,13 +130,13 @@ struct ice_adapter *ice_adapter_get(stru
  */
 void ice_adapter_put(struct pci_dev *pdev)
 {
+	const struct ice_pf *pf = pci_get_drvdata(pdev);
+	unsigned long index = pf->adapter->index;
 	struct ice_adapter *adapter;
-	unsigned long index;
 
-	index = ice_adapter_xa_index(pdev);
 	scoped_guard(mutex, &ice_adapters_mutex) {
 		adapter = xa_load(&ice_adapters, index);
-		if (WARN_ON(!adapter))
+		if (WARN_ON(!adapter || adapter != pf->adapter))
 			return;
 		if (!refcount_dec_and_test(&adapter->refcount))
 			return;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-05-18 14:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-13  9:09 [PATCH] ice: Fix wrong dsn read in ice_adapter_put Cyrill Gorcunov
2026-05-17 12:53 ` Simon Horman
2026-05-17 22:21   ` [PATCH v2] " Cyrill Gorcunov
2026-05-18 10:02     ` Cyrill Gorcunov
2026-05-18 14:36       ` Cyrill Gorcunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox