summaryrefslogtreecommitdiffstats
path: root/hw/usb-serial.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-serial.c
parent23f2166d736dcf7854e674a160694b151ee0725b (diff)
downloadhqemu-d44168fffa07fc57e61a37da65e9348661dec887.zip
hqemu-d44168fffa07fc57e61a37da65e9348661dec887.tar.gz
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-serial.c')
-rw-r--r--hw/usb-serial.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/hw/usb-serial.c b/hw/usb-serial.c
index c3f3401..1410b11 100644
--- a/hw/usb-serial.c
+++ b/hw/usb-serial.c
@@ -594,6 +594,9 @@ static USBDevice *usb_serial_init(const char *filename)
return NULL;
dev = usb_create(NULL /* FIXME */, "usb-serial");
+ if (!dev) {
+ return NULL;
+ }
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
if (vendorid)
qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);
OpenPOWER on IntegriCloud