[libvirt] [PATCH] virsh: Don't leak disk targets in cmdDomBlkError

Michal Privoznik posted 1 patch 9 weeks ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/d55be92286f3b0143e263d42ce421d5c441f2cab.1557751067.git.mprivozn@redhat.com
tools/virsh-domain-monitor.c | 2 ++
1 file changed, 2 insertions(+)

[libvirt] [PATCH] virsh: Don't leak disk targets in cmdDomBlkError

Posted by Michal Privoznik 9 weeks ago
The virDomainGetDiskErrors() API copies disk targets into @disks
array that we allocate. But we forgot to free it:

==140828== 16 bytes in 4 blocks are definitely lost in loss record 41 of 242
==140828==    at 0x4C2F08F: malloc (vg_replace_malloc.c:299)
==140828==    by 0x8C406D9: strdup (in /lib64/libc-2.28.so)
==140828==    by 0x5377DD3: virStrdup (virstring.c:966)
==140828==    by 0x54C112F: testDomainGetDiskErrors (test_driver.c:3068)
==140828==    by 0x55C863D: virDomainGetDiskErrors (libvirt-domain.c:10988)
==140828==    by 0x15D1FA: cmdDomBlkError (virsh-domain-monitor.c:1215)
==140828==    by 0x17F1A8: vshCommandRun (vsh.c:1335)
==140828==    by 0x13489E: main (virsh.c:920)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---

Pushed under trivial rule.

 tools/virsh-domain-monitor.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index d87475f6f6..d2b7e5a059 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -1229,6 +1229,8 @@ cmdDomBlkError(vshControl *ctl, const vshCmd *cmd)
     ret = true;
 
  cleanup:
+    for (i = 0; i < count; i++)
+        VIR_FREE(disks[i].disk);
     VIR_FREE(disks);
     virshDomainFree(dom);
     return ret;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list