]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainGetStatsIOThread: Don't leak array with 0 iothreads
authorPeter Krempa <pkrempa@redhat.com>
Wed, 19 Feb 2020 07:40:59 +0000 (08:40 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 19 Feb 2020 09:24:31 +0000 (10:24 +0100)
qemuMonitorGetIOThreads returns a NULL-terminated list even when 0
iothreads are present. The caller didn't perform cleanup if there were 0
iothreads leaking the array.

https://bugzilla.redhat.com/show_bug.cgi?id=1804548

Fixes: d1eac92784573559b6fd56836e33b215c89308e3
Reported-by: Jing Yan <jiyan@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_driver.c

index f686b858cf9796d9998743bc1564454e6098a5d3..39e1f044e027ebd1d6775a3c96ef5a045f9d56ba 100644 (file)
@@ -21759,8 +21759,12 @@ qemuDomainGetStatsIOThread(virQEMUDriverPtr driver,
     if ((niothreads = qemuDomainGetIOThreadsMon(driver, dom, &iothreads)) < 0)
         return -1;
 
-    if (niothreads == 0)
-        return 0;
+    /* qemuDomainGetIOThreadsMon returns a NULL-terminated list, so we must free
+     * it even if it returns 0 */
+    if (niothreads == 0) {
+        ret = 0;
+        goto cleanup;
+    }
 
     if (virTypedParamListAddUInt(params, niothreads, "iothread.count") < 0)
         goto cleanup;