[PATCH v4 3/3] PCI: Avoid size overflow for bridge 32bit resource

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When mmio64_mask is not used, overall size should not bigger than 2G
for single bridge.
Get out early, so we could have chance to have some child resources get
assigned instead of failing all of them, as bridge resource assigned
is too small when overflow happens.

Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx>

---
 drivers/pci/setup-bus.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

Index: linux-2.6/drivers/pci/setup-bus.c
===================================================================
--- linux-2.6.orig/drivers/pci/setup-bus.c
+++ linux-2.6/drivers/pci/setup-bus.c
@@ -957,6 +957,16 @@ static int pbus_size_mem(struct pci_bus
 					  (r->flags & mask) != type3))
 				continue;
 			r_size = resource_size(r);
+
+			/* reject oversize early */
+			if (!mem64_mask &&
+			    ((unsigned long long)size + r_size > (1ULL<<31))) {
+				dev_warn(&dev->dev, "disabling BAR %d: %pR size %#llx overflow bridge's)\n",
+					i, r, (unsigned long long)size);
+				r->flags = 0;
+				continue;
+			}
+
 #ifdef CONFIG_PCI_IOV
 			/* put SRIOV requested res to the optional list */
 			if (realloc_head && i >= PCI_IOV_RESOURCES &&
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux