diff mbox

pci init: Check if devfn exceeding the max devices number supported on bus

Message ID 376108071.2560.472.stgit@k1 (mailing list archive)
State New, archived
Headers show

Commit Message

Ken CC Aug. 23, 2010, 5:53 a.m. UTC
None
diff mbox

Patch

diff --git a/hw/pci.c b/hw/pci.c
index a09fbac..f6f00c6 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -675,6 +675,10 @@  static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
         error_report("PCI: no slot/function available for %s, all in use", name);
         return NULL;
     found: ;
+    } else if (devfn > PCIBUS_MAX_DEVICES - 1) {
+        error_report("PCI: devfn is out of bus capacity."
+                        " Only %d devices supported.", PCIBUS_MAX_DEVICES);
+        return NULL;
     } else if (bus->devices[devfn]) {
         error_report("PCI: slot %d function %d not available for %s, in use by %s",
                      PCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name);