Fix -usbdevice crash

If -usbdevice is used on a machine with no USB busses, usb_create
will fail and return NULL.  Patch below handles this failure gracefully
rather than crashing when we try to init the device.

Signed-off-by: Paul Brook <paul@codesourcery.com>
This commit is contained in:
Paul Brook 2010-02-25 13:29:06 +00:00
parent 23f2166d73
commit d44168fffa
4 changed files with 12 additions and 0 deletions

View file

@ -1491,6 +1491,9 @@ static USBDevice *usb_net_init(const char *cmdline)
}
dev = usb_create(NULL /* FIXME */, "usb-net");
if (!dev) {
return NULL;
}
qdev_set_nic_properties(&dev->qdev, &nd_table[idx]);
qdev_init_nofail(&dev->qdev);
return dev;