Re: [PATCH] libxl: implement NUMA capabilities reporting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

...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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]