]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: plug memory leak on cmdBlkdeviotune() sucessful path
authorAlex Jia <ajia@redhat.com>
Thu, 8 Dec 2011 06:09:56 +0000 (14:09 +0800)
committerEric Blake <eblake@redhat.com>
Thu, 8 Dec 2011 23:38:03 +0000 (16:38 -0700)
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@redhat.com>
tools/virsh.c

index a51478f525b4041988ddb6c5c9f83ca81a1e8e57..e6e4f8b87654240186511712c31bc07c366a9da6 100644 (file)
@@ -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));