]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Don't leak temporary list of USB devices
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 26 Mar 2012 14:33:58 +0000 (16:33 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 4 Apr 2012 13:09:41 +0000 (15:09 +0200)
and add debug message when adding USB device
to the list of active devices.

src/qemu/qemu_hostdev.c

index 329e3fc054265c2e33a0d43c138976422493f9ba..d4d746162c2ae27c142a9fdca8dbbdf038823190 100644 (file)
@@ -559,10 +559,7 @@ qemuPrepareHostdevUSBDevices(struct qemud_driver *driver,
                                 hostdev->source.subsys.u.usb.product);
 
             if (!usb)
-                return -1;
-
-            hostdev->source.subsys.u.usb.bus = usbDeviceGetBus(usb);
-            hostdev->source.subsys.u.usb.device = usbDeviceGetDevno(usb);
+                goto cleanup;
 
             if ((tmp = usbDeviceListFind(driver->activeUsbHostdevs, usb))) {
                 const char *other_name = usbDeviceGetUsedBy(tmp);
@@ -579,6 +576,9 @@ qemuPrepareHostdevUSBDevices(struct qemud_driver *driver,
                 goto cleanup;
             }
 
+            hostdev->source.subsys.u.usb.bus = usbDeviceGetBus(usb);
+            hostdev->source.subsys.u.usb.device = usbDeviceGetDevno(usb);
+
             if (usbDeviceListAdd(list, usb) < 0) {
                 usbFreeDevice(usb);
                 goto cleanup;
@@ -594,6 +594,9 @@ qemuPrepareHostdevUSBDevices(struct qemud_driver *driver,
     for (i = 0; i < usbDeviceListCount(list); i++) {
         tmp = usbDeviceListGet(list, i);
         usbDeviceSetUsedBy(tmp, name);
+
+        VIR_DEBUG("Adding %03d.%03d dom=%s to activeUsbHostdevs",
+                  usbDeviceGetBus(tmp), usbDeviceGetDevno(tmp), name);
         if (usbDeviceListAdd(driver->activeUsbHostdevs, tmp) < 0) {
             usbFreeDevice(tmp);
             goto inactivedevs;