[PATCH 1/2] x86/PCI: fix infinity loop in search for 64bit BAR placement

From: Christian KÃnig
Date: Tue Nov 21 2017 - 05:20:00 EST


Break the loop if we can't find some address space for a 64bit BAR.

Signed-off-by: Christian KÃnig <christian.koenig@xxxxxxx>
---
arch/x86/pci/fixup.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
index 1e996df687a3..5328e86f73eb 100644
--- a/arch/x86/pci/fixup.c
+++ b/arch/x86/pci/fixup.c
@@ -696,8 +696,13 @@ static void pci_amd_enable_64bit_bar(struct pci_dev *dev)
res->end = 0xfd00000000ull - 1;

/* Just grab the free area behind system memory for this */
- while ((conflict = request_resource_conflict(&iomem_resource, res)))
+ while ((conflict = request_resource_conflict(&iomem_resource, res))) {
+ if (conflict->end >= res->end) {
+ kfree(res);
+ return;
+ }
res->start = conflict->end + 1;
+ }

dev_info(&dev->dev, "adding root bus resource %pR\n", res);

--
2.11.0


--------------D7D53C3D67A2F260910835E5
Content-Type: text/x-patch;
name="0002-x86-PCI-only-enable-a-64bit-BAR-on-single-socket-AMD.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment;
filename*0="0002-x86-PCI-only-enable-a-64bit-BAR-on-single-socket-AMD.pa";
filename*1="tch"