[PATCH 0/3] Couple of memleak fixes

*** BLURB HERE *** Michal Prívozník (3): virDomainFSDefFree: Unref private data virDomainNetDefClear: Free @persistent name qemuTestParseCapabilitiesArch: Free @binary src/conf/domain_conf.c | 2 ++ tests/testutilsqemu.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) -- 2.24.1

The privateData object is allocated in virDomainFSDefNew() but never unref'd. ==119642== 480 bytes in 20 blocks are definitely lost in loss record 656 of 671 ==119642== at 0x4837B86: calloc (vg_replace_malloc.c:762) ==119642== by 0x57806A0: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6000.7) ==119642== by 0x4AE7392: virAllocVar (viralloc.c:331) ==119642== by 0x4B64395: virObjectNew (virobject.c:241) ==119642== by 0x48F1464: qemuDomainFSPrivateNew (qemu_domain.c:1427) ==119642== by 0x4BBF004: virDomainFSDefNew (domain_conf.c:2307) ==119642== by 0x4BD859A: virDomainFSDefParseXML (domain_conf.c:11217) ==119642== by 0x4BF9DD1: virDomainDefParseXML (domain_conf.c:21179) ==119642== by 0x4BFCD5B: virDomainDefParseNode (domain_conf.c:21943) ==119642== by 0x4BFCC36: virDomainDefParse (domain_conf.c:21901) ==119642== by 0x4BFCCCB: virDomainDefParseFile (domain_conf.c:21924) ==119642== by 0x114A9D: testCompareXMLToArgv (qemuxml2argvtest.c:452) Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/conf/domain_conf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a2603f095e..bd2ca53f1d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2324,6 +2324,7 @@ void virDomainFSDefFree(virDomainFSDefPtr def) VIR_FREE(def->dst); virDomainDeviceInfoClear(&def->info); VIR_FREE(def->virtio); + virObjectUnref(def->privateData); VIR_FREE(def); } -- 2.24.1

On Fri, Feb 21, 2020 at 08:44:49AM +0100, Michal Privoznik wrote:
The privateData object is allocated in virDomainFSDefNew() but never unref'd.
==119642== 480 bytes in 20 blocks are definitely lost in loss record 656 of 671 ==119642== at 0x4837B86: calloc (vg_replace_malloc.c:762) ==119642== by 0x57806A0: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6000.7) ==119642== by 0x4AE7392: virAllocVar (viralloc.c:331) ==119642== by 0x4B64395: virObjectNew (virobject.c:241) ==119642== by 0x48F1464: qemuDomainFSPrivateNew (qemu_domain.c:1427) ==119642== by 0x4BBF004: virDomainFSDefNew (domain_conf.c:2307) ==119642== by 0x4BD859A: virDomainFSDefParseXML (domain_conf.c:11217) ==119642== by 0x4BF9DD1: virDomainDefParseXML (domain_conf.c:21179) ==119642== by 0x4BFCD5B: virDomainDefParseNode (domain_conf.c:21943) ==119642== by 0x4BFCC36: virDomainDefParse (domain_conf.c:21901) ==119642== by 0x4BFCCCB: virDomainDefParseFile (domain_conf.c:21924) ==119642== by 0x114A9D: testCompareXMLToArgv (qemuxml2argvtest.c:452)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/conf/domain_conf.c | 1 + 1 file changed, 1 insertion(+)
Fixes: 5120577ed79f89e172e3deed534fa9b585f4701f Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The persistent alias name @persistent is allocated in virDomainNetDefParseXML() but never freed. ==119642== 22 bytes in 2 blocks are definitely lost in loss record 178 of 671 ==119642== at 0x483579F: malloc (vg_replace_malloc.c:309) ==119642== by 0x58F89F1: xmlStrndup (in /usr/lib64/libxml2.so.2.9.9) ==119642== by 0x4BA3B74: virXMLPropString (virxml.c:520) ==119642== by 0x4BDB0C5: virDomainNetDefParseXML (domain_conf.c:11876) ==119642== by 0x4BF9EF4: virDomainDefParseXML (domain_conf.c:21196) ==119642== by 0x4BFCD5B: virDomainDefParseNode (domain_conf.c:21943) ==119642== by 0x4BFCC36: virDomainDefParse (domain_conf.c:21901) ==119642== by 0x4BFCCCB: virDomainDefParseFile (domain_conf.c:21924) ==119642== by 0x114A9D: testCompareXMLToArgv (qemuxml2argvtest.c:452) ==119642== by 0x13894F: virTestRun (testutils.c:143) ==119642== by 0x11F46E: mymain (qemuxml2argvtest.c:1316) ==119642== by 0x13A60E: virTestMain (testutils.c:839 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/conf/domain_conf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bd2ca53f1d..cef49df3f8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2444,6 +2444,7 @@ virDomainNetDefClear(virDomainNetDefPtr def) VIR_FREE(def->backend.tap); VIR_FREE(def->backend.vhost); + VIR_FREE(def->teaming.persistent); VIR_FREE(def->virtPortProfile); VIR_FREE(def->script); VIR_FREE(def->domain_name); -- 2.24.1

On Fri, Feb 21, 2020 at 08:44:50AM +0100, Michal Privoznik wrote:
The persistent alias name @persistent is allocated in virDomainNetDefParseXML() but never freed.
==119642== 22 bytes in 2 blocks are definitely lost in loss record 178 of 671 ==119642== at 0x483579F: malloc (vg_replace_malloc.c:309) ==119642== by 0x58F89F1: xmlStrndup (in /usr/lib64/libxml2.so.2.9.9) ==119642== by 0x4BA3B74: virXMLPropString (virxml.c:520) ==119642== by 0x4BDB0C5: virDomainNetDefParseXML (domain_conf.c:11876) ==119642== by 0x4BF9EF4: virDomainDefParseXML (domain_conf.c:21196) ==119642== by 0x4BFCD5B: virDomainDefParseNode (domain_conf.c:21943) ==119642== by 0x4BFCC36: virDomainDefParse (domain_conf.c:21901) ==119642== by 0x4BFCCCB: virDomainDefParseFile (domain_conf.c:21924) ==119642== by 0x114A9D: testCompareXMLToArgv (qemuxml2argvtest.c:452) ==119642== by 0x13894F: virTestRun (testutils.c:143) ==119642== by 0x11F46E: mymain (qemuxml2argvtest.c:1316) ==119642== by 0x13A60E: virTestMain (testutils.c:839
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/conf/domain_conf.c | 1 + 1 file changed, 1 insertion(+)
Fixes: fb0509d06ac57434c2edbd81ee63deb32a0e598a Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The variable is allocated, but never freed. ==119642== 29 bytes in 1 blocks are definitely lost in loss record 409 of 671 ==119642== at 0x483579F: malloc (vg_replace_malloc.c:309) ==119642== by 0x5AB075F: __vasprintf_internal (in /lib64/libc-2.29.so) ==119642== by 0x57C1A28: g_vasprintf (in /usr/lib64/libglib-2.0.so.0.6000.7) ==119642== by 0x579A0CC: g_strdup_vprintf (in /usr/lib64/libglib-2.0.so.0.6000.7) ==119642== by 0x4AE6D58: vir_g_strdup_printf (glibcompat.c:197) ==119642== by 0x136EEE: qemuTestParseCapabilitiesArch (testutilsqemu.c:291) ==119642== by 0x138506: testQemuInfoSetArgs (testutilsqemu.c:763) ==119642== by 0x135FFF: mymain (qemuxml2argvtest.c:3093) ==119642== by 0x13A60E: virTestMain (testutils.c:839) ==119642== by 0x1368C2: main (qemuxml2argvtest.c:3121) Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/testutilsqemu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 0cb9a7456d..4dd5664f7b 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -288,8 +288,8 @@ qemuTestParseCapabilitiesArch(virArch arch, const char *capsFile) { virQEMUCapsPtr qemuCaps = NULL; - char *binary = g_strdup_printf("/usr/bin/qemu-system-%s", - virArchToString(arch)); + g_autofree char *binary = g_strdup_printf("/usr/bin/qemu-system-%s", + virArchToString(arch)); if (!(qemuCaps = virQEMUCapsNewBinary(binary)) || virQEMUCapsLoadCache(arch, qemuCaps, capsFile) < 0) -- 2.24.1

On Fri, Feb 21, 2020 at 08:44:51AM +0100, Michal Privoznik wrote:
The variable is allocated, but never freed.
==119642== 29 bytes in 1 blocks are definitely lost in loss record 409 of 671 ==119642== at 0x483579F: malloc (vg_replace_malloc.c:309) ==119642== by 0x5AB075F: __vasprintf_internal (in /lib64/libc-2.29.so) ==119642== by 0x57C1A28: g_vasprintf (in /usr/lib64/libglib-2.0.so.0.6000.7) ==119642== by 0x579A0CC: g_strdup_vprintf (in /usr/lib64/libglib-2.0.so.0.6000.7) ==119642== by 0x4AE6D58: vir_g_strdup_printf (glibcompat.c:197) ==119642== by 0x136EEE: qemuTestParseCapabilitiesArch (testutilsqemu.c:291) ==119642== by 0x138506: testQemuInfoSetArgs (testutilsqemu.c:763) ==119642== by 0x135FFF: mymain (qemuxml2argvtest.c:3093) ==119642== by 0x13A60E: virTestMain (testutils.c:839) ==119642== by 0x1368C2: main (qemuxml2argvtest.c:3121)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/testutilsqemu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Fixes: 42b3e5b9e4b919644afe55a815992c07fb79b9dc Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Michal Privoznik