Fix leak of usbDevice struct when initializing cgroups

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>
This commit is contained in:
Daniel P. Berrange 2013-02-05 15:14:46 +00:00
parent 202535601c
commit 3e86e8f327
2 changed files with 8 additions and 2 deletions

View 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) {

View 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);
}
}