]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix leak of usbDevice struct when initializing cgroups
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 5 Feb 2013 15:14:46 +0000 (15:14 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 5 Feb 2013 19:22:25 +0000 (19:22 +0000)
When iterating over USB host devices to setup cgroups, the
usbDevice object was leaked in both LXC and QEMU driers

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/lxc/lxc_cgroup.c
src/qemu/qemu_cgroup.c

index 1984c5f8e51bc9f390828335f0e7fec859a99e61..4936219fe5cdae682889e5318b961a55141b2dc4 100644 (file)
@@ -427,8 +427,11 @@ static int virLXCCgroupSetupDeviceACL(virDomainDefPtr def,
                 goto cleanup;
 
             if (usbDeviceFileIterate(usb, virLXCSetupHostUsbDeviceCgroup,
-                                     cgroup) < 0)
+                                     cgroup) < 0) {
+                usbFreeDevice(usb);
                 goto cleanup;
+            }
+            usbFreeDevice(usb);
             break;
         case VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES:
             switch (hostdev->source.caps.type) {
index 376a21dd5696df693b775d83ed4d78e4825a068d..e0796cd4e537a7a56788b53b26e4dca17beb0cb5 100644 (file)
@@ -302,8 +302,11 @@ int qemuSetupCgroup(virQEMUDriverPtr driver,
                 goto cleanup;
 
             if (usbDeviceFileIterate(usb, qemuSetupHostUsbDeviceCgroup,
-                                     &data) < 0)
+                                     &data) < 0) {
+                usbFreeDevice(usb);
                 goto cleanup;
+            }
+            usbFreeDevice(usb);
         }
     }