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