Skip to contentSkip to conversation

libxl: initialise nr_dom_vcpus to fix 4a6070ea9

PATCH In review Wei Liu 3 participants 3 messages Oct 24, 2016

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH v2 1/1 libxl: initialise nr_dom_vcpus to fix 4a6070ea9

Clang complains nr_dom_vcpus may be used uninitialised after 4a6070ea9.

The real issue is vinfo can be NULL and nr_dom_vcpus remains uninitialised if previous call fails.

Initialise nr_dom_vcpus to 0 at the beginning of the loop to fix the issue.

---
Cc: Ian Jackson <[email protected]>
Cc: Dario Faggioli <[email protected]>
Cc: Juergen Gross <[email protected]>

---
 tools/libxl/libxl_numa.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/libxl/libxl_numa.c +2 -1
index fd64c22..a8a75f8 100644
@@ -206,8 +206,9 @@ static int nr_vcpus_on_nodes(libxl__gc *gc, libxl_cputopology *tinfo,
 
     for (i = 0; i < nr_doms; i++) {
         libxl_vcpuinfo *vinfo = NULL;
+        int nr_dom_vcpus = 0;
         libxl_cpupoolinfo cpupool_info;
-        int cpupool, nr_dom_vcpus;
+        int cpupool;
 
         libxl_cpupoolinfo_init(&cpupool_info);
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Wei Liu

Clang complains nr_dom_vcpus may be used uninitialised after 4a6070ea9.

The real issue is vinfo can be NULL and nr_dom_vcpus remains uninitialised if previous call fails.

Initialise nr_dom_vcpus to 0 at the beginning of the loop to fix the issue.

Thanks and Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Acked-by on v2 1/1
#2 lore raw
In reply to Wei Liu

Wei Liu writes ("[PATCH v2] libxl: initialise nr_dom_vcpus to fix 4a6070ea9"):

Quoted 8 lines

Clang complains nr_dom_vcpus may be used uninitialised after 4a6070ea9.

The real issue is vinfo can be NULL and nr_dom_vcpus remains uninitialised if previous call fails.

Initialise nr_dom_vcpus to 0 at the beginning of the loop to fix the issue.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel