render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
d76c62
From 388611da8330fb19693caf927680e9af08d5738e Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <388611da8330fb19693caf927680e9af08d5738e@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Wed, 19 Feb 2020 15:10:27 +0100
d76c62
Subject: [PATCH] qemuDomainGetStatsIOThread: Don't leak array with 0 iothreads
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
qemuMonitorGetIOThreads returns a NULL-terminated list even when 0
d76c62
iothreads are present. The caller didn't perform cleanup if there were 0
d76c62
iothreads leaking the array.
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1804548
d76c62
d76c62
Fixes: d1eac92784573559b6fd56836e33b215c89308e3
d76c62
Reported-by: Jing Yan <jiyan@redhat.com>
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
(cherry picked from commit 9bf9e0ae6af38c806f4672ca7b12a6b38d5a9581)
d76c62
Message-Id: <eef614566ad383a1393a295caa6e2550381eb3e7.1582120424.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/qemu/qemu_driver.c | 8 ++++++--
d76c62
 1 file changed, 6 insertions(+), 2 deletions(-)
d76c62
d76c62
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
d76c62
index af81c4a6e4..69e4f7264b 100644
d76c62
--- a/src/qemu/qemu_driver.c
d76c62
+++ b/src/qemu/qemu_driver.c
d76c62
@@ -21532,8 +21532,12 @@ qemuDomainGetStatsIOThread(virQEMUDriverPtr driver,
d76c62
     if ((niothreads = qemuDomainGetIOThreadsMon(driver, dom, &iothreads)) < 0)
d76c62
         return -1;
d76c62
 
d76c62
-    if (niothreads == 0)
d76c62
-        return 0;
d76c62
+    /* qemuDomainGetIOThreadsMon returns a NULL-terminated list, so we must free
d76c62
+     * it even if it returns 0 */
d76c62
+    if (niothreads == 0) {
d76c62
+        ret = 0;
d76c62
+        goto cleanup;
d76c62
+    }
d76c62
 
d76c62
     if (virTypedParamListAddUInt(params, niothreads, "iothread.count") < 0)
d76c62
         goto cleanup;
d76c62
-- 
d76c62
2.25.0
d76c62