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