From: Alex Jia Date: Thu, 8 Dec 2011 06:09:56 +0000 (+0800) Subject: virsh: plug memory leak on cmdBlkdeviotune() sucessful path X-Git-Tag: v0.9.9-rc1~108 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecf75f83dc5f83b43d24695e1323446137b68770;p=thirdparty%2Flibvirt.git virsh: plug memory leak on cmdBlkdeviotune() sucessful path 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 * 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 --- diff --git a/tools/virsh.c b/tools/virsh.c index a51478f525..e6e4f8b876 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));