When the CH driver starts a domain virCHProcessSetupIOThreads() is called eventually which in turn calls virCHMonitorGetIOThreads(). The latter returns an array of iothreads which is never freed leading to a memleak: 130 (104 direct, 26 indirect) bytes in 1 blocks are definitely lost in loss record 1,804 of 1,998 at 0x484CEF3: calloc (vg_replace_malloc.c:1675) by 0x4F0E7A9: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.8000.5) by 0xB3A9359: virCHMonitorGetIOThreads (ch_monitor.c:1183) by 0xB3AA5BB: virCHProcessSetupIOThreads (ch_process.c:348) by 0xB3AAC59: virCHProcessSetup (ch_process.c:480) by 0xB3AC75A: virCHProcessStart (ch_process.c:973) by 0xB39B7D4: chDomainCreateXML (ch_driver.c:246) by 0x4CC9D32: virDomainCreateXML (libvirt-domain.c:188) by 0x168F91: remoteDispatchDomainCreateXML (remote_daemon_dispatch_stubs.h:5186) by 0x168F18: remoteDispatchDomainCreateXMLHelper (remote_daemon_dispatch_stubs.h:5167) by 0x4B20066: virNetServerProgramDispatchCall (virnetserverprogram.c:423) by 0x4B1FB99: virNetServerProgramDispatch (virnetserverprogram.c:299) Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/ch/ch_process.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 9a85f7869e..cbf98faaf0 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -344,6 +344,7 @@ virCHProcessSetupIOThreads(virDomainObj *vm) virDomainIOThreadInfo **iothreads = NULL; size_t i; int niothreads; + int ret = -1; if ((niothreads = virCHMonitorGetIOThreads(priv->monitor, &iothreads)) < 0) return -1; @@ -351,9 +352,16 @@ virCHProcessSetupIOThreads(virDomainObj *vm) for (i = 0; i < niothreads; i++) { VIR_DEBUG("IOThread index = %zu , tid = %d", i, iothreads[i]->iothread_id); if (virCHProcessSetupIOThread(vm, iothreads[i]) < 0) - return -1; + goto cleanup; } - return 0; + + ret = 0; + cleanup: + for (i = 0; i < niothreads; i++) { + virDomainIOThreadInfoFree(iothreads[i]); + } + g_free(iothreads); + return ret; } static int -- 2.48.1