[libvirt] [PATCH] qemu_cgroup: initialize mem_mask to NULL

Pavel Hrdina phrdina at redhat.com
Tue Feb 17 13:24:14 UTC 2015


If 'virNumaGetHostNodeset()' fails then the error path will try to free
uninitialized pointer mem_mask. Introduced by commit af2a1f058.

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---

Pushed under trivial rule.

 src/qemu/qemu_cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index fc46450..7b8eed0 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -791,32 +791,32 @@ qemuInitCgroup(virQEMUDriverPtr driver,
 static void
 qemuRestoreCgroupState(virDomainObjPtr vm)
 {
-    char *mem_mask;
+    char *mem_mask = NULL;
     int empty = -1;
     qemuDomainObjPrivatePtr priv = vm->privateData;
     virBitmapPtr all_nodes;
 
     if (!(all_nodes = virNumaGetHostNodeset()))
         goto error;
 
     if (!(mem_mask = virBitmapFormat(all_nodes)))
         goto error;
 
     if ((empty = virCgroupHasEmptyTasks(priv->cgroup,
                                         VIR_CGROUP_CONTROLLER_CPUSET)) <= 0)
         goto error;
 
     if (virCgroupSetCpusetMems(priv->cgroup, mem_mask) < 0)
         goto error;
 
  cleanup:
     VIR_FREE(mem_mask);
     virBitmapFree(all_nodes);
     return;
 
  error:
     virResetLastError();
     VIR_DEBUG("Couldn't restore cgroups to meaningful state");
     goto cleanup;
 }
 
-- 
2.0.5




More information about the libvir-list mailing list