From 3e86e8f327351b06d2fb3c431d9eafa7b8be6bed Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 5 Feb 2013 15:14:46 +0000 Subject: [PATCH] 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 --- src/lxc/lxc_cgroup.c | 5 ++++- src/qemu/qemu_cgroup.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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); } } -- GitLab