From aff427a1ca09945082a4ec21aee2960306800fb0 Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Mon, 21 Apr 2008 16:02:48 -0700 Subject: 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 Signed-off-by: Chris Wright Signed-off-by: Avi Kivity Signed-off-by: Anthony Liguori --- hw/e1000.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'hw/e1000.c') diff --git a/hw/e1000.c b/hw/e1000.c index 1729db28e1..b0fe917342 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -1063,6 +1063,9 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) d = (E1000State *)pci_register_device(bus, "e1000", sizeof(E1000State), devfn, NULL, NULL); + if (!d) + return NULL; + pci_conf = d->dev.config; memset(pci_conf, 0, 256); -- cgit v1.2.1