summaryrefslogtreecommitdiff
path: root/hw/ne2000.c
diff options
context:
space:
mode:
authorChris Wright <chrisw@sous-sol.org>2008-04-21 16:02:48 -0700
committerAnthony Liguori <aliguori@us.ibm.com>2009-05-01 09:47:14 -0500
commitaff427a1ca09945082a4ec21aee2960306800fb0 (patch)
tree9aa24e8dbc09dc035a99e034c0347d2c7da3c919 /hw/ne2000.c
parente6a6dfe454c6b43abf9d5df8170950c4a9f28920 (diff)
downloadqemu-aff427a1ca09945082a4ec21aee2960306800fb0.tar.gz
Pci nic: pci_register_device can fail
The pci_register_device() call in PCI nic initialization routines can fail. Handle this failure and propagate a meaningful error message to the user instead of generating a SEGV. Cc: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Chris Wright <chrisw@sous-sol.org> Signed-off-by: Avi Kivity <avi@qumranet.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/ne2000.c')
-rw-r--r--hw/ne2000.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/hw/ne2000.c b/hw/ne2000.c
index 99612e2589..613ac411f8 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -810,6 +810,9 @@ PCIDevice *pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn)
"NE2000", sizeof(PCINE2000State),
devfn,
NULL, NULL);
+ if (!d)
+ return NULL;
+
pci_conf = d->dev.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_REALTEK);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_REALTEK_8029);