Re: [PATCH] PCI: fix bug introduced in pci_save_pcix_state()

From: Bjorn Helgaas
Date: Mon Feb 24 2025 - 10:49:53 EST


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

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
>