[libvirt] [PATCH] Memory Leak Fix: Check def->info->alias before assigning

Daniel P. Berrange berrange at redhat.com
Wed Nov 27 09:25:39 UTC 2013


On Wed, Nov 27, 2013 at 04:01:45AM +0530, Nehal J Wani wrote:
> On running the command make -C tests valgrind, there used to be a bunch of
> memory leaks shown by valgrind. Specifically, one can check it by running:
> libtool --mode=execute valgrind --quiet --leak-check=full --suppressions=./.valgrind.supp qemuhotplugtest
> The issue was that def->info->alias was already malloc'ed by xmlStrndup in
> virDomainDeviceInfoParseXML (domain_conf.c:3439). The new alias was being
> assigned again without freeing the old one in qemuAssignDeviceAliases().
> This patch checks if the entity exists, and frees accordingly, hence making
> valgrind cry lesser.

The 'alias' attribute should *not* be parsed from the XML provided by
the user. It should only be parsed in the live state XML. In the latter
case no codepath should take us to qemuAssignDeviceAliases. So this is
certainly not the right fix. It sounds like the test case is flawed to
me.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list