[libvirt] [PATCH] daemon: Plug memory leak on remoteDispatchAuthList

Alex Jia ajia at redhat.com
Mon Feb 20 10:05:47 UTC 2012


Detected by valgrind. Leak is introuduced in commit fcdfa31.

* daemon/remote.c (remoteDispatchAuthList): fix memory leak on failure path.

* Actual result

==26844== 150,592 bytes in 9,602 blocks are definitely lost in loss record 735 of 738
==26844==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==26844==    by 0x36AEAFEDE7: __vasprintf_chk (in /lib64/libc-2.12.so)
==26844==    by 0x36C3A59B03: virVasprintf (stdio2.h:199)
==26844==    by 0x36C3A59BA7: virAsprintf (util.c:1827)
==26844==    by 0x4335F5: remoteDispatchAuthListHelper (remote.c:2054)
==26844==    by 0x36C3B10394: virNetServerProgramDispatch (virnetserverprogram.c:416)
==26844==    by 0x36C3B11620: virNetServerHandleJob (virnetserver.c:164)
==26844==    by 0x36C3A57AAB: virThreadPoolWorker (threadpool.c:144)
==26844==    by 0x36C3A573C8: virThreadHelper (threads-pthread.c:161)
==26844==    by 0x36AEE077F0: start_thread (in /lib64/libpthread-2.12.so)
==26844==    by 0x36AEAE570C: clone (in /lib64/libc-2.12.so)

Notes, the test is in a loop, so you will see a quite big leaks.

Signed-off-by: Alex Jia <ajia at redhat.com>
---
 daemon/remote.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 74a5f16..9018c15 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -2054,6 +2054,7 @@ remoteDispatchAuthList(virNetServerPtr server ATTRIBUTE_UNUSED,
             if (virAsprintf(&ident, "pid:%lld,uid:%d",
                             (long long) callerPid, callerUid) < 0) {
                 virReportOOMError();
+                VIR_FREE(ident);
                 goto cleanup;
             }
             VIR_INFO("Bypass polkit auth for privileged client %s", ident);
-- 
1.7.1




More information about the libvir-list mailing list