[PATCH] vircgroup: Don't leak @parent in virCgroupEnableMissingControllers()

Pavel Hrdina phrdina at redhat.com
Wed Feb 3 20:44:39 UTC 2021


On Wed, Feb 03, 2021 at 09:06:52PM +0100, Michal Privoznik wrote:
> A memory leak was identified in
> virCgroupEnableMissingControllers():
> 
> ==11680==    at 0x483EAE5: calloc (vg_replace_malloc.c:760)
> ==11680==    by 0x4E51780: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6701.0)
> ==11680==    by 0x4908618: virCgroupNew (vircgroup.c:701)
> ==11680==    by 0x49096F4: virCgroupEnableMissingControllers (vircgroup.c:1146)
> ==11680==    by 0x4909B17: virCgroupNewMachineSystemd (vircgroup.c:1228)
> ==11680==    by 0x4909E94: virCgroupNewMachine (vircgroup.c:1313)
> ==11680==    by 0x1694FDBC: qemuInitCgroup (qemu_cgroup.c:946)
> ==11680==    by 0x1695046B: qemuSetupCgroup (qemu_cgroup.c:1083)
> ==11680==    by 0x16A60126: qemuProcessLaunch (qemu_process.c:7077)
> ==11680==    by 0x16A61504: qemuProcessStart (qemu_process.c:7384)
> ==11680==    by 0x169B84C2: qemuDomainObjStart (qemu_driver.c:6590)
> ==11680==    by 0x169B8776: qemuDomainCreateWithFlags (qemu_driver.c:6641)
> 
> What happens is that new virCgroup is created and stored into
> @parent. Then, if @tokens is not empty the for() loop is entered
> into where another virCgroup is created and @parent is replaced
> with this new virCgroup. But nothing freed the old @parent.
> 
> Fixes: 77291414c7a8745cf4d2b06d3c38d269cfbcfe32
> Reported-by: Andrea Bolognani <abologna at redhat.com>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/util/vircgroup.c | 1 +
>  1 file changed, 1 insertion(+)

Oops, thanks for fixing this.

Reviewed-by: Pavel Hrdina <phrdina at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20210203/0734685d/attachment-0001.sig>


More information about the libvir-list mailing list