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>
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index 36991f8..1a11bc5 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -592,6 +592,9 @@
/* create guest device */
dev = usb_create(NULL /* FIXME */, "usb-storage");
+ if (!dev) {
+ return NULL;
+ }
qdev_prop_set_drive(&dev->qdev, "drive", dinfo);
if (qdev_init(&dev->qdev) < 0)
return NULL;