9c6c51
From a9c5b686c6eeb63ad98603dc99ee95bb0dafda62 Mon Sep 17 00:00:00 2001
9c6c51
Message-Id: <a9c5b686c6eeb63ad98603dc99ee95bb0dafda62@dist-git>
9c6c51
From: John Ferlan <jferlan@redhat.com>
9c6c51
Date: Sat, 21 Jul 2018 09:34:12 -0400
9c6c51
Subject: [PATCH] src: Fix memory leak in virNWFilterBindingDispose
9c6c51
MIME-Version: 1.0
9c6c51
Content-Type: text/plain; charset=UTF-8
9c6c51
Content-Transfer-Encoding: 8bit
9c6c51
9c6c51
https://bugzilla.redhat.com/show_bug.cgi?id=1603025
9c6c51
9c6c51
Commit b57a9aec neglected to VIR_FREE(binding->filtername) as seen
9c6c51
in the following valgrind report
9c6c51
9c6c51
==6423== 17,328 bytes in 1,083 blocks are definitely lost in loss record 2,275 of 2,297
9c6c51
==6423==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
9c6c51
==6423==    by 0x83B20C9: strdup (in /usr/lib64/libc-2.17.so)
9c6c51
==6423==    by 0x533C144: virStrdup (virstring.c:977)
9c6c51
==6423==    by 0x54BDD53: virGetNWFilterBinding (datatypes.c:865)
9c6c51
==6423==    by 0x318D633C: nwfilterBindingCreateXML (nwfilter_driver.c:767)
9c6c51
==6423==    by 0x54F3FC5: virNWFilterBindingCreateXML (libvirt-nwfilter.c:701)
9c6c51
==6423==    by 0x539CE29: virDomainConfNWFilterInstantiate (domain_nwfilter.c:116)
9c6c51
==6423==    by 0x31E516C2: qemuInterfaceBridgeConnect (qemu_interface.c:589)
9c6c51
==6423==    by 0x31D98B56: qemuBuildInterfaceCommandLine (qemu_command.c:8418)
9c6c51
==6423==    by 0x31D9F783: qemuBuildNetCommandLine (qemu_command.c:8673)
9c6c51
==6423==    by 0x31D9F783: qemuBuildCommandLine (qemu_command.c:10354)
9c6c51
==6423==    by 0x31DE355F: qemuProcessLaunch (qemu_process.c:6292)
9c6c51
==6423==    by 0x31DE7881: qemuProcessStart (qemu_process.c:6686)
9c6c51
9c6c51
and
9c6c51
9c6c51
==6423== 17,328 bytes in 1,083 blocks are definitely lost in loss record 2,276 of 2,297
9c6c51
==6423==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
9c6c51
==6423==    by 0x83B20C9: strdup (in /usr/lib64/libc-2.17.so)
9c6c51
==6423==    by 0x533C144: virStrdup (virstring.c:977)
9c6c51
==6423==    by 0x54BDD53: virGetNWFilterBinding (datatypes.c:865)
9c6c51
==6423==    by 0x318D641F: nwfilterBindingLookupByPortDev (nwfilter_driver.c:678)
9c6c51
==6423==    by 0x54F3B63: virNWFilterBindingLookupByPortDev (libvirt-nwfilter.c:593)
9c6c51
==6423==    by 0x539CBC5: virDomainConfNWFilterTeardownImpl.isra.0 (domain_nwfilter.c:136)
9c6c51
==6423==    by 0x539CFA5: virDomainConfVMNWFilterTeardown (domain_nwfilter.c:170)
9c6c51
==6423==    by 0x31DE5651: qemuProcessStop (qemu_process.c:6912)
9c6c51
==6423==    by 0x31E37974: qemuDomainDestroyFlags (qemu_driver.c:2229)
9c6c51
==6423==    by 0x54C24BB: virDomainDestroy (libvirt-domain.c:475)
9c6c51
==6423==    by 0x1589A2: remoteDispatchDomainDestroy (remote_daemon_dispatch_stubs.h:4827)
9c6c51
==6423==    by 0x1589A2: remoteDispatchDomainDestroyHelper (remote_daemon_dispatch_stubs.h:4803)
9c6c51
9c6c51
Signed-off-by: John Ferlan <jferlan@redhat.com>
9c6c51
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
9c6c51
(cherry picked from commit 329f2347d2215edb3925ec21c73bb52b7b5aa310)
9c6c51
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
9c6c51
---
9c6c51
 src/datatypes.c | 1 +
9c6c51
 1 file changed, 1 insertion(+)
9c6c51
9c6c51
diff --git a/src/datatypes.c b/src/datatypes.c
9c6c51
index 878a1c5b5f..caf035f178 100644
9c6c51
--- a/src/datatypes.c
9c6c51
+++ b/src/datatypes.c
9c6c51
@@ -893,6 +893,7 @@ virNWFilterBindingDispose(void *obj)
9c6c51
     VIR_DEBUG("release binding %p %s", binding, binding->portdev);
9c6c51
 
9c6c51
     VIR_FREE(binding->portdev);
9c6c51
+    VIR_FREE(binding->filtername);
9c6c51
     virObjectUnref(binding->conn);
9c6c51
 }
9c6c51
 
9c6c51
-- 
9c6c51
2.18.0
9c6c51