usb-bus: Don't allow attaching a device to a bus with no free ports
authorHans de Goede <hdegoede@redhat.com>
Fri, 27 May 2011 12:46:27 +0000 (14:46 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Thu, 23 Jun 2011 09:28:06 +0000 (11:28 +0200)
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb-bus.c

index 480956d..0a49921 100644 (file)
@@ -181,6 +181,11 @@ static void do_attach(USBDevice *dev)
                 dev->product_desc);
         return;
     }
+    if (bus->nfree == 0) {
+        fprintf(stderr, "Warning: tried to attach usb device %s to a bus with no free ports\n",
+                dev->product_desc);
+        return;
+    }
     if (dev->port_path) {
         QTAILQ_FOREACH(port, &bus->free, next) {
             if (strcmp(port->path, dev->port_path) == 0) {