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

[Xen-devel] [PATCH 2/2] xenmon: initialise dummy array



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@xxxxxxxxxx>
---
 tools/xenmon/xenbaked.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/xenmon/xenbaked.c b/tools/xenmon/xenbaked.c
index 782f0c1..3d9e0ed 100644
--- a/tools/xenmon/xenbaked.c
+++ b/tools/xenmon/xenbaked.c
@@ -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++) {
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.