From: Daniel P. Berrange Date: Tue, 5 Feb 2013 15:14:46 +0000 (+0000) Subject: Fix leak of usbDevice struct when initializing cgroups X-Git-Tag: v1.0.3-rc1~216 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e86e8f327351b06d2fb3c431d9eafa7b8be6bed;p=thirdparty%2Flibvirt.git 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 --- diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index 1984c5f8e5..4936219fe5 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -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) { diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 376a21dd56..e0796cd4e5 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -302,8 +302,11 @@ int qemuSetupCgroup(virQEMUDriverPtr driver, goto cleanup; if (usbDeviceFileIterate(usb, qemuSetupHostUsbDeviceCgroup, - &data) < 0) + &data) < 0) { + usbFreeDevice(usb); goto cleanup; + } + usbFreeDevice(usb); } }