diff mbox

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

Message ID 1404420379-20983-3-git-send-email-yinghai@kernel.org
State Not Applicable
Headers show

Commit Message

Yinghai Lu July 3, 2014, 8:46 p.m. UTC
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@kernel.org>

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

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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 &&