[libvirt] [PATCH] libxl: implement NUMA capabilities reporting

John Ferlan jferlan at redhat.com
Tue Aug 20 17:01:52 UTC 2013


On 08/16/2013 05:46 PM, Jim Fehlig wrote:
> From: Dario Faggioli <dario.faggioli at citrix.com>

...snip...

> +
> + cleanup:
> +    if (ret != 0) {
> +        for (i = 0; i < nr_nodes; i++)
> +            VIR_FREE(cpus[i]);
> +        virCapabilitiesFreeNUMAInfo(caps);
> +    }
> +

Coverity got grumpy with respect to the above loop.  While I can only
assume logically that 'nr_nodes' is not changed if libxl_get_numainfo()
returns NULL, Coverity doesn't assume that.

Also, even if libxl_get_numainfo() did return data and nr_nodes had a
value, if the "else" condition fails, eg "if (cpu_topo == NULL ||
nr_cpus == 0) {", then 'nr_nodes > 0', but 'cpus' is still NULL, which
will cause sudden death syndrome :-).

The following resolves Coverity's complaint and keeps things safer:

-        for (i = 0; i < nr_nodes; i++)
+        for (i = 0; cpus && i < nr_nodes; i++)

John




More information about the libvir-list mailing list