diff options
author | Blue Swirl <blauwirbel@gmail.com> | 2009-11-15 14:30:03 +0000 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2009-11-15 14:30:03 +0000 |
commit | c364c974d9ab90e25e7887f516da65d2811ba5e3 (patch) | |
tree | 60f36af6af7556ee70b697fe6932105f158b7192 /hw/pci.c | |
parent | 3e65aaf5b2a01272fcd71d9b4efa7fe94c9c11af (diff) |
PCI: make duplicate devfn allocation fatal
Only two callers of pci_create_simple/pci_register_device bothered
to check the return value. Other cases were prone to crashing with
spurious NULL pointer dereferences.
Make QEMU exit with an error message when devfn is attempted to
be duplicated, also applies to case when the bus is full. Remove
checks.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/pci.c')
-rw-r--r-- | hw/pci.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -499,10 +499,11 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, if (!bus->devices[devfn]) goto found; } - return NULL; + hw_error("PCI: no devfn available for %s, all in use\n", name); found: ; } else if (bus->devices[devfn]) { - return NULL; + hw_error("PCI: devfn %d not available for %s, in use by %s\n", devfn, + name, bus->devices[devfn]->name); } pci_dev->bus = bus; pci_dev->devfn = devfn; @@ -1273,7 +1274,6 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) pci_dev = do_pci_register_device(pci_dev, bus, base->name, devfn, info->config_read, info->config_write, info->header_type); - assert(pci_dev); rc = info->init(pci_dev); if (rc != 0) return rc; |