Skip to contentSkip to conversation

PCI: fix bug introduced in pci_save_pcix_state()

PATCH In review Ashish Kalra 2 participants 2 messages Feb 23, 2025 – Feb 24, 2025 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: fix bug introduced in pci_save_pcix_state()

From: Ashish Kalra <[email protected]>

For PCIe devices which don't have PCI_CAP_ID_PCIX, this change in pci_save_pcix_state() causes pci_save_state() to return -ENOMEM error and causes e1000e driver probe to fail as follows:
..

[   15.891676] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[   15.921816] e1000e 0000:21:00.0: probe with driver e1000e failed with error -12

...

Fixes 7d90d8d2bb1b ("PCI: Avoid pointless capability searches")
---
 drivers/pci/pci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pci/pci.c +4 -4
index ccd029339079..685463ea392b 100644
@@ -1743,14 +1743,14 @@ static int pci_save_pcix_state(struct pci_dev *dev)
 	struct pci_cap_saved_state *save_state;
 	u8 pos;
 
-	save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX);
-	if (!save_state)
-		return -ENOMEM;
-
 	pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
 	if (!pos)
 		return 0;
 
+	save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX);
+	if (!save_state)
+		return -ENOMEM;
+
 	pci_read_config_word(dev, pos + PCI_X_CMD,
 			     (u16 *)save_state->cap.data);
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 6 lines · Ashish Kalra

From: Ashish Kalra <[email protected]>

For PCIe devices which don't have PCI_CAP_ID_PCIX, this change in pci_save_pcix_state() causes pci_save_state() to return -ENOMEM error and causes e1000e driver probe to fail as follows:
..

Quoted 6 lines
[   15.891676] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[   15.921816] e1000e 0000:21:00.0: probe with driver e1000e failed with error -12

...

Fixes 7d90d8d2bb1b ("PCI: Avoid pointless capability searches")

I dropped that patch for now, so if you're using current -next you shouldn't see this issue.

Quoted 30 lines
---
 drivers/pci/pci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pci/pci.c +4 -4
index ccd029339079..685463ea392b 100644
@@ -1743,14 +1743,14 @@ static int pci_save_pcix_state(struct pci_dev *dev)
 	struct pci_cap_saved_state *save_state;
 	u8 pos;
 
-	save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX);
-	if (!save_state)
-		return -ENOMEM;
-
 	pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
 	if (!pos)
 		return 0;
 
+	save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX);
+	if (!save_state)
+		return -ENOMEM;
+
 	pci_read_config_word(dev, pos + PCI_X_CMD,
 			     (u16 *)save_state->cap.data);
 
Signature · 1 line
2.34.1