public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: fix bug introduced in pci_save_pcix_state()
@ 2025-02-23  5:07 Ashish Kalra
  2025-02-24 15:43 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Ashish Kalra @ 2025-02-23  5:07 UTC (permalink / raw)
  To: bhelgaas, ilpo.jarvinen, alex.williamson; +Cc: linux-pci, linux-kernel

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


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

* Re: [PATCH] PCI: fix bug introduced in pci_save_pcix_state()
  2025-02-23  5:07 [PATCH] PCI: fix bug introduced in pci_save_pcix_state() Ashish Kalra
@ 2025-02-24 15:43 ` Bjorn Helgaas
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2025-02-24 15:43 UTC (permalink / raw)
  To: Ashish Kalra
  Cc: bhelgaas, ilpo.jarvinen, alex.williamson, linux-pci, linux-kernel

On Sun, Feb 23, 2025 at 05:07:00AM +0000, Ashish Kalra wrote:
> 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>

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

> ---
>  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
> 

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

end of thread, other threads:[~2025-02-24 15:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-23  5:07 [PATCH] PCI: fix bug introduced in pci_save_pcix_state() Ashish Kalra
2025-02-24 15:43 ` Bjorn Helgaas

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