xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, xen-devel@lists.xen.org
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 2/2] xenmon: initialise dummy array
Date: Wed, 10 Feb 2016 16:26:25 +0000	[thread overview]
Message-ID: <1455121585-22659-2-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1455121585-22659-1-git-send-email-ian.campbell@citrix.com>

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

  reply	other threads:[~2016-02-10 16:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-10 16:26 [PATCH 1/2] xenmon: close qos_fd when finished with it in alloc_qos_data Ian Campbell
2016-02-10 16:26 ` Ian Campbell [this message]
2016-02-11 11:19   ` [PATCH 2/2] xenmon: initialise dummy array Wei Liu
2016-02-11 11:18 ` [PATCH 1/2] xenmon: close qos_fd when finished with it in alloc_qos_data Wei Liu
2016-02-11 15:38   ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455121585-22659-2-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).