x86/PCI: Fix infinite loop in search for 64bit BAR placement
authorChristian König <christian.koenig@amd.com>
Wed, 29 Nov 2017 14:12:27 +0000 (15:12 +0100)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 6 Dec 2017 20:57:19 +0000 (14:57 -0600)
Break the loop if we can't find some address space for a 64bit BAR.

Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
arch/x86/pci/fixup.c

index 1e996df..5328e86 100644 (file)
@@ -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);