[PATCH] virsh: plug memory leak on cmdBlkdeviotune() sucessful path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Alex Jia <ajia@xxxxxxxxxx>

Detected by valgrind. Leak introduced in commit e9bd9a0:

* tools/virsh.c: fix memory leak on cmdBlkdeviotune.

* how to reproduce?
  % valgrind -v --leak-check=full virsh blkdeviotune <domain name> <block device>

* actual valgrind result:

==12759== 576 bytes in 1 blocks are definitely lost in loss record 18 of 29
==12759==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==12759==    by 0x42134E: _vshCalloc.clone.2 (virsh.c:422)
==12759==    by 0x4217CB: cmdBlkdeviotune (virsh.c:6364)
==12759==    by 0x4136A2: vshCommandRun (virsh.c:16363)
==12759==    by 0x4253FB: main (virsh.c:17865)
==12759==
==12759== LEAK SUMMARY:
==12759==    definitely lost: 576 bytes in 1 blocks
==12759==    indirectly lost: 0 bytes in 0 blocks
==12759==      possibly lost: 0 bytes in 0 blocks
==12759==    still reachable: 126,964 bytes in 1,342 blocks
==12759==         suppressed: 0 bytes in 0 blocks

Signed-off-by: Alex Jia <ajia@xxxxxxxxxx>
---
 tools/virsh.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index a51478f..e6e4f8b 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -6400,8 +6400,8 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
             }
         }
 
-        virDomainFree(dom);
-        return true;
+        ret =  true;
+        goto cleanup;
     } else {
         /* Set the block I/O throttle, match by opt since parameters can be 0 */
         params = vshCalloc(ctl, nparams, sizeof(*params));
-- 
1.7.1

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]