[PATCH 03/15] PCI: Abort BAR resize only if saving the resized BAR fails
From: Ilpo Järvinen
Date: Tue Dec 01 2026 - 10:59:51 EST
pci_do_resource_release_and_resize() saves and releases the BARs of the
device that share the bridge window with the BAR being resized, and
rolls back if saving any of them fails. Only the resized BAR has to be
saved and released for the resize to be possible. Another BAR that
cannot be saved remains assigned, which may prevent the bridge window
from being adjusted, but resize may succeed in some cases despite it.
Roll back only if saving the resized BAR fails. Leave the other BARs
that cannot be saved in place and continue.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
---
drivers/pci/setup-bus.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 608ca7afbfb8..ea0039fb6ad0 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -2407,8 +2407,11 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int size
continue;
ret = pci_dev_res_add_to_list(&saved, pdev, r, 0, 0);
- if (ret)
- goto restore;
+ if (ret) {
+ if (i == resno)
+ goto restore;
+ continue;
+ }
pci_release_resource(pdev, i);
}
--
2.47.3