9119d9
From ef895aea24b07fc419496a3e2780629380d061b5 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <ef895aea24b07fc419496a3e2780629380d061b5@dist-git>
9119d9
From: Peter Krempa <pkrempa@redhat.com>
9119d9
Date: Wed, 5 Nov 2014 16:32:38 +0100
9119d9
Subject: [PATCH] remote: Fix memory leak in remoteConnectGetAllDomainStats
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1158715
9119d9
9119d9
The remote call actually doesn't free the arguments array so we leak
9119d9
memory in case a domain list is specified. As the remote domain list
9119d9
array consists only of stolen pointers from the actual domain objects
9119d9
it's sufficient just to free the array.
9119d9
9119d9
Valgrind message:
9119d9
==1081452== 64 bytes in 1 blocks are definitely lost in loss record 632 of 726
9119d9
==1081452==    at 0x4C296D0: calloc (vg_replace_malloc.c:618)
9119d9
==1081452==    by 0x4EA5CB4: virAllocN (viralloc.c:191)
9119d9
==1081452==    by 0x505D21E: remoteConnectGetAllDomainStats (remote_driver.c:7785)
9119d9
==1081452==    by 0x50081AA: virDomainListGetStats (libvirt-domain.c:11080)
9119d9
==1081452==    by 0x155249: cmdDomstats (virsh-domain-monitor.c:2147)
9119d9
==1081452==    by 0x12FB73: vshCommandRun (virsh.c:1935)
9119d9
==1081452==    by 0x133FEB: main (virsh.c:3719)
9119d9
9119d9
(cherry picked from commit bf1f8e280c330f51833189d40a99dc894205a129)
9119d9
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/remote/remote_driver.c | 1 +
9119d9
 1 file changed, 1 insertion(+)
9119d9
9119d9
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
9119d9
index de021d4..6f7c894 100644
9119d9
--- a/src/remote/remote_driver.c
9119d9
+++ b/src/remote/remote_driver.c
9119d9
@@ -7842,6 +7842,7 @@ remoteConnectGetAllDomainStats(virConnectPtr conn,
9119d9
         VIR_FREE(elem);
9119d9
     }
9119d9
     virDomainStatsRecordListFree(tmpret);
9119d9
+    VIR_FREE(args.doms.doms_val);
9119d9
     xdr_free((xdrproc_t)xdr_remote_connect_get_all_domain_stats_ret,
9119d9
              (char *) &ret;;
9119d9
 
9119d9
-- 
9119d9
2.1.3
9119d9