aboutsummaryrefslogtreecommitdiffstats
path: root/hw/usb-bus.c
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2010-02-25 13:29:06 +0000
committerPaul Brook <paul@codesourcery.com>2010-02-25 13:29:06 +0000
commitd44168fffa07fc57e61a37da65e9348661dec887 (patch)
treef3a41713d7a4e7cdef21cd3a7c2f5a49104f2368 /hw/usb-bus.c
parent23f2166d736dcf7854e674a160694b151ee0725b (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-bus.c')
-rw-r--r--hw/usb-bus.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 54027dfc4..7c823147a 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -102,6 +102,9 @@ USBDevice *usb_create(USBBus *bus, const char *name)
USBDevice *usb_create_simple(USBBus *bus, const char *name)
{
USBDevice *dev = usb_create(bus, name);
+ if (!dev) {
+ hw_error("Failed to create USB device '%s'\n", name);
+ }
qdev_init_nofail(&dev->qdev);
return dev;
}