]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libxl: Resolve possible NULL dereference
authorJohn Ferlan <jferlan@redhat.com>
Tue, 20 Aug 2013 17:20:56 +0000 (13:20 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 20 Aug 2013 17:20:56 +0000 (13:20 -0400)
If we reached cleanup: prior to allocating cpus, it was possible that
'nr_nodes' had a value, but cpus was NULL leading to a possible NULL
deref. Add a 'cpus' as an end condition to for loop

src/libxl/libxl_conf.c

index 01626b98a059c0dc8d46bd238c954b047aa753cc..8129c7fe1f2d6a03021f7dd4476c5cb76c1c36d2 100644 (file)
@@ -196,7 +196,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
 
  cleanup:
     if (ret != 0) {
-        for (i = 0; i < nr_nodes; i++)
+        for (i = 0; cpus && i < nr_nodes; i++)
             VIR_FREE(cpus[i]);
         virCapabilitiesFreeNUMAInfo(caps);
     }