aboutsummaryrefslogtreecommitdiff
path: root/hw/usb-bus.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2011-11-22 12:39:58 +0100
committerGerd Hoffmann <kraxel@redhat.com>2011-11-22 13:38:12 +0100
commit2af2a1b8d05a1a64c5005ed930137632b9d5aa22 (patch)
tree48def53b1e3398c8be21922623aa6bb34d5cd6f1 /hw/usb-bus.c
parent40897c9c160393df922dfdb59cfa210048d3071d (diff)
usb: make usb_create_simple catch and pass up errors.
Use qdev_init() instead of qdev_init_nofail(), usb device initialization can fail, most common case being port and device speed mismatch. Handle failures correctly and pass up NULL pointers then. Also fixup usb_create_simple() callers (only one was buggy) to properly check for NULL pointers before referncing the usb_create_simple() return value. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb-bus.c')
-rw-r--r--hw/usb-bus.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 93f640d370..f8b9807232 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -139,10 +139,17 @@ USBDevice *usb_create(USBBus *bus, const char *name)
USBDevice *usb_create_simple(USBBus *bus, const char *name)
{
USBDevice *dev = usb_create(bus, name);
+ int rc;
+
if (!dev) {
- hw_error("Failed to create USB device '%s'\n", name);
+ error_report("Failed to create USB device '%s'\n", name);
+ return NULL;
+ }
+ rc = qdev_init(&dev->qdev);
+ if (rc < 0) {
+ error_report("Failed to initialize USB device '%s'\n", name);
+ return NULL;
}
- qdev_init_nofail(&dev->qdev);
return dev;
}