The current reset process saves the device's config space state before reset and restores it afterward. However, when a device is in an error state before reset, config space reads may return error values instead of valid data. This results in saving corrupted values that get written back to the device during state restoration. Add validation to prevent writing error values to the device when restoring the config space state after reset. Signed-off-by: Farhan Ali --- drivers/pci/pci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b0f4d98036cd..0dd95d782022 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1825,6 +1825,9 @@ static void pci_restore_config_dword(struct pci_dev *pdev, int offset, if (!force && val == saved_val) return; + if (PCI_POSSIBLE_ERROR(saved_val)) + return; + for (;;) { pci_dbg(pdev, "restore config %#04x: %#010x -> %#010x\n", offset, val, saved_val); -- 2.43.0