From: Michal Privoznik Date: Wed, 8 Jan 2020 08:18:29 +0000 (+0100) Subject: virchrdev: Don't leak @dev member of virChrdevHashEntry struct X-Git-Tag: v6.1.0-rc1~511 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aab37799943ef033f73f1101c189145099902ac5;p=thirdparty%2Flibvirt.git virchrdev: Don't leak @dev member of virChrdevHashEntry struct 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 Reviewed-by: Erik Skultety --- 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); }