]> xenbits.xensource.com Git - libvirt.git/commitdiff
admin: Resolve leaked reference to private data
authorErik Skultety <eskultet@redhat.com>
Mon, 7 Sep 2015 15:28:22 +0000 (17:28 +0200)
committerErik Skultety <eskultet@redhat.com>
Tue, 8 Sep 2015 08:07:18 +0000 (10:07 +0200)
Running valgrind on a very simplistic program consisting only of
opening and closing admin connection (virAdmConnect{Open,Close}) shows a
leak in remoteAdminPrivNew, because the last reference to privateData is
not decremented, thus the object won't be disposed. This patch unrefs
the privateData object once we closed the active connection to daemon,
making further use of this connection  useless.

==24577==    at 0x4A089C7: calloc (in /usr/lib64/valgrind/vgpreload_***linux.so)
==24577==    by 0x4E8835F: virAllocVar (viralloc.c:560)
==24577==    by 0x4EDFA5C: virObjectNew (virobject.c:193)
==24577==    by 0x4EDFBD4: virObjectLockableNew (virobject.c:219)
==24577==    by 0x4C14DAF: remoteAdminPrivNew (libvirt-admin.c:152)
==24577==    by 0x4C1537E: virAdmConnectOpen (libvirt-admin.c:308)
==24577==    by 0x400BAD: main (listservers.c:39)

==24577== LEAK SUMMARY:
==24577==    definitely lost: 80 bytes in 1 blocks
==24577==    indirectly lost: 840 bytes in 6 blocks
==24577==      possibly lost: 0 bytes in 0 blocks
==24577==    still reachable: 12,179 bytes in 199 blocks
==24577==         suppressed: 0 bytes in 0 blocks

src/libvirt-admin.c

index b3fd0b3a8cf2227eea0110a2e6a986cead44de2d..5a4fc4833ddff4215e0a954a5c1d8506b20861f5 100644 (file)
@@ -132,6 +132,7 @@ remoteAdminPrivFree(void *opaque)
     virAdmConnectPtr conn = opaque;
 
     remoteAdminConnectClose(conn);
+    virObjectUnref(conn->privateData);
 }
 
 static remoteAdminPrivPtr