[libvirt] [PATCH 1/4] virchrdev: Don't leak @dev member of virChrdevHashEntry struct

Michal Privoznik mprivozn at redhat.com
Wed Jan 8 08:18:29 UTC 2020


When opening a console to a domain, we put a tuple of {path,
virStreamPtr} into a hash table that's private to the domain.
This is to ensure only one client at most has the console stream
open. Later, when the console is closed, the tuple is removed
from the hash table and freed. Except, @path won't be freed.

==234102== 60 bytes in 5 blocks are definitely lost in loss record 436 of 651
==234102==    at 0x4836753: malloc (vg_replace_malloc.c:307)
==234102==    by 0x5549110: g_malloc (in /usr/lib64/libglib-2.0.so.0.6000.6)
==234102==    by 0x5562D1E: g_strdup (in /usr/lib64/libglib-2.0.so.0.6000.6)
==234102==    by 0x4A5A917: virChrdevOpen (virchrdev.c:412)
==234102==    by 0x17B64645: qemuDomainOpenConsole (qemu_driver.c:17309)
==234102==    by 0x4BC8031: virDomainOpenConsole (libvirt-domain.c:9662)
==234102==    by 0x13F854: remoteDispatchDomainOpenConsole (remote_daemon_dispatch_stubs.h:9211)
==234102==    by 0x13F72F: remoteDispatchDomainOpenConsoleHelper (remote_daemon_dispatch_stubs.h:9178)
==234102==    by 0x4AB0685: virNetServerProgramDispatchCall (virnetserverprogram.c:430)
==234102==    by 0x4AB01F0: virNetServerProgramDispatch (virnetserverprogram.c:302)
==234102==    by 0x4AB700B: virNetServerProcessMsg (virnetserver.c:136)
==234102==    by 0x4AB70CB: virNetServerHandleJob (virnetserver.c:153)

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/conf/virchrdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c
index d4ca3188c5..7657c41ece 100644
--- a/src/conf/virchrdev.c
+++ b/src/conf/virchrdev.c
@@ -225,6 +225,7 @@ static void virChrdevHashEntryFree(void *data)
     /* delete lock file */
     virChrdevLockFileRemove(ent->dev);
 
+    g_free(ent->dev);
     g_free(ent);
 }
 
-- 
2.24.1




More information about the libvir-list mailing list