]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virchrdev: Don't leak @dev member of virChrdevHashEntry struct
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 8 Jan 2020 08:18:29 +0000 (09:18 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 16 Jan 2020 13:13:47 +0000 (14:13 +0100)
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@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/conf/virchrdev.c

index d4ca3188c5038305d5516d4f8c05da4fff8b505d..7657c41eceb97c10680baffb1bb10b3e451b6093 100644 (file)
@@ -225,6 +225,7 @@ static void virChrdevHashEntryFree(void *data)
     /* delete lock file */
     virChrdevLockFileRemove(ent->dev);
 
+    g_free(ent->dev);
     g_free(ent);
 }