diff options
author | Paul Brook <paul@codesourcery.com> | 2010-02-25 13:29:06 +0000 |
---|---|---|
committer | Paul Brook <paul@codesourcery.com> | 2010-02-25 13:29:06 +0000 |
commit | d44168fffa07fc57e61a37da65e9348661dec887 (patch) | |
tree | f3a41713d7a4e7cdef21cd3a7c2f5a49104f2368 /hw/usb-msd.c | |
parent | 23f2166d736dcf7854e674a160694b151ee0725b (diff) |
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>
Diffstat (limited to 'hw/usb-msd.c')
-rw-r--r-- | hw/usb-msd.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 36991f8833..1a11bc557e 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -592,6 +592,9 @@ static USBDevice *usb_msd_init(const char *filename) /* 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; |