Skip to content

Commit 08d9eae

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: Fix BAR resize rollback path overwriting ret
The commit 337b1b5 ("PCI: Fix restoring BARs on BAR resize rollback path") added BAR rollback to pci_do_resource_release_and_resize() in case of resize failure. On the rollback, pci_claim_resource() is called, which can fail and the code is prepared for that possibility. pci_claim_resource()'s return value, however, overwrites the original value of ret so pci_do_resource_release_and_resize() will return an incorrect value in the end (as pci_claim_resource() normally succeeds, in practice ret will be 0). Fix the issue by directly calling pci_claim_resource() inside the if (). Fixes: 337b1b5 ("PCI: Fix restoring BARs on BAR resize rollback path") Reported-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://lore.kernel.org/linux-pci/aW_w1oFQCzUxGYtu@intel.com/ Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260121131417.9582-2-ilpo.jarvinen@linux.intel.com
1 parent 8f0b4cc commit 08d9eae

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

drivers/pci/setup-bus.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2556,8 +2556,7 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int size
25562556

25572557
restore_dev_resource(dev_res);
25582558

2559-
ret = pci_claim_resource(dev, i);
2560-
if (ret)
2559+
if (pci_claim_resource(dev, i))
25612560
continue;
25622561

25632562
if (i < PCI_BRIDGE_RESOURCES) {

0 commit comments

Comments
 (0)