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

Osier Yang jyang at redhat.com
Thu Dec 8 06:17:59 UTC 2011


On 2011年12月08日 14:09, ajia at redhat.com wrote:
> From: Alex Jia<ajia at redhat.com>
>
> 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 at redhat.com>
> ---
>   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));


ACK.

Osier




More information about the libvir-list mailing list