]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virsh: fix memleak when starting a guest with invalid fd
authorJincheng Miao <jmiao@redhat.com>
Thu, 20 Feb 2014 09:29:15 +0000 (17:29 +0800)
committerEric Blake <eblake@redhat.com>
Thu, 20 Feb 2014 12:40:13 +0000 (05:40 -0700)
commit6c1059ef24f72a5d35cbdb0e01b443a8f55e5a15
tree7119dc3619efb4510b5fde8d37d72b4a0c8ffbcd
parent39aad72510a324cb50c20d5082fa0fe0edf1e565
virsh: fix memleak when starting a guest with invalid fd

When start a guest with --pass-fd, if the argument of --pass-fd is invalid,
virsh will exit, but doesn't free the variable 'dom'.

The valgrind said:
...
==24569== 63 (56 direct, 7 indirect) bytes in 1 blocks are definitely lost in loss record 130 of 234
==24569==    at 0x4C2A1D4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==24569==    by 0x4E879A4: virAllocVar (viralloc.c:544)
==24569==    by 0x4EBD625: virObjectNew (virobject.c:190)
==24569==    by 0x4F3A18A: virGetDomain (datatypes.c:226)
==24569==    by 0x4F9311F: remoteDomainLookupByName (remote_driver.c:6636)
==24569==    by 0x4F44F20: virDomainLookupByName (libvirt.c:2277)
==24569==    by 0x12F616: vshCommandOptDomainBy (virsh-domain.c:105)
==24569==    by 0x131C79: cmdStart (virsh-domain.c:3330)
==24569==    by 0x12C4AB: vshCommandRun (virsh.c:1752)
==24569==    by 0x127001: main (virsh.c:3218)

https://bugzilla.redhat.com/show_bug.cgi?id=1067338

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
tools/virsh-domain.c