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