[libvirt] [PATCH 1/2] qemu: Fix memleak in qemuBuildNumaArgStr

Michal Privoznik mprivozn at redhat.com
Wed Jun 6 11:13:13 UTC 2018


We are allocating each individual buffer in @nodeBackends array
but never free it.

==22516== 96 bytes in 4 blocks are definitely lost in loss record 166 of 195
==22516==    at 0x4C2EF26: calloc (vg_replace_malloc.c:711)
==22516==    by 0x5D2C7D5: virAlloc (viralloc.c:144)
==22516==    by 0x56FAABD: qemuBuildNumaArgStr (qemu_command.c:7543)
==22516==    by 0x5701835: qemuBuildCommandLine (qemu_command.c:10112)
==22516==    by 0x575D794: qemuProcessCreatePretendCmd (qemu_process.c:6568)
==22516==    by 0x113338: testCompareXMLToArgv (qemuxml2argvtest.c:549)
==22516==    by 0x138CA3: virTestRun (testutils.c:180)
==22516==    by 0x136CD1: mymain (qemuxml2argvtest.c:2825)
==22516==    by 0x13AD58: virTestMain (testutils.c:1118)
==22516==    by 0x137351: main (qemuxml2argvtest.c:2874)

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/qemu/qemu_command.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e85c5ef804..fb5bb26ad1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7641,8 +7641,10 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
     VIR_FREE(cpumask);
 
     if (nodeBackends) {
-        for (i = 0; i < ncells; i++)
+        for (i = 0; i < ncells; i++) {
             virBufferFreeAndReset(nodeBackends[i]);
+            VIR_FREE(nodeBackends[i]);
+        }
 
         VIR_FREE(nodeBackends);
     }
-- 
2.16.4




More information about the libvir-list mailing list