]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
PCI: Skip Resizable BAR restore on read error
authorMarco Nenciarini <mnencia@kcore.it>
Fri, 17 Apr 2026 13:24:36 +0000 (15:24 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 27 Apr 2026 14:47:03 +0000 (09:47 -0500)
commitee7471fe968d210939be9046089a924cd23c8c3b
tree9f413035241c5404cbe2a88f6c2932ebbac06aed
parentd462c8e89e84bfb6417e6b4c88e0cb7cc747ba41
PCI: Skip Resizable BAR restore on read error

pci_restore_rebar_state() uses the Resizable BAR Control register to decide
how many BARs to restore (nbars) and which BAR each iteration addresses
(bar_idx).

When a device does not respond, config reads typically return
PCI_ERROR_RESPONSE (~0).  Both fields are 3 bits wide, so nbars and bar_idx
both evaluate to 7, past the spec's valid ranges for both fields.
pci_resource_n() then returns an unrelated resource slot, whose size is
used to derive a nonsensical value written back to the Resizable BAR
Control register.

Bail out if any Resizable BAR Control read returns PCI_ERROR_RESPONSE. No
further BARs are touched, which is safe because a config read that returns
PCI_ERROR_RESPONSE indicates the device is unreachable and restoration is
pointless.

Fixes: d3252ace0bc6 ("PCI: Restore resized BAR state on resume")
Signed-off-by: Marco Nenciarini <mnencia@kcore.it>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/666cac19b5daa0ab0e0ab64454e76b4d24465dbd.1776429882.git.mnencia@kcore.it
drivers/pci/rebar.c