]> xenbits.xensource.com Git - xen.git/commitdiff
xenmon: initialise dummy array
authorIan Campbell <ian.campbell@citrix.com>
Wed, 10 Feb 2016 16:26:25 +0000 (16:26 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 11 Feb 2016 15:12:18 +0000 (15:12 +0000)
This is just used to expand the shared backing file to the expected
size (whether this is actually necessary I'm not sure). Rather than
leaking some small amount of the processes' heap set the array to
zeroes.

While at it add a check that the malloc succeeded before using the
result.

Compile tested only.

CID: 1056095 (use of uninitialised data)

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/xenmon/xenbaked.c

index 782f0c1fd143ab94c4853185786537d9dd92392f..3d9e0ed90043ef775bcf03d3363f16b2ca6218a5 100644 (file)
@@ -663,6 +663,11 @@ static void alloc_qos_data(int ncpu)
     }
     pgsize = getpagesize();
     dummy = malloc(pgsize);
+    if (!dummy) {
+        PERROR("malloc");
+        exit(EXIT_FAILURE);
+    }
+    memset(dummy, 0, pgsize);
 
     for (n=0; n<ncpu; n++) {