public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Ashish Kalra <Ashish.Kalra@amd.com>
To: <bhelgaas@google.com>, <ilpo.jarvinen@linux.intel.com>,
	<alex.williamson@redhat.com>
Cc: <linux-pci@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] PCI: fix bug introduced in pci_save_pcix_state()
Date: Sun, 23 Feb 2025 05:07:00 +0000	[thread overview]
Message-ID: <20250223050700.4635-1-Ashish.Kalra@amd.com> (raw)

From: Ashish Kalra <ashish.kalra@amd.com>

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")
Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
---
 drivers/pci/pci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index ccd029339079..685463ea392b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -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);
 
-- 
2.34.1


             reply	other threads:[~2025-02-23  5:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-23  5:07 Ashish Kalra [this message]
2025-02-24 15:43 ` [PATCH] PCI: fix bug introduced in pci_save_pcix_state() Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250223050700.4635-1-Ashish.Kalra@amd.com \
    --to=ashish.kalra@amd.com \
    --cc=alex.williamson@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox