From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: [PATCH 2/2] xenmon: initialise dummy array Date: Thu, 11 Feb 2016 11:19:48 +0000 Message-ID: <20160211111948.GE17384@citrix.com> References: <1455121585-22659-1-git-send-email-ian.campbell@citrix.com> <1455121585-22659-2-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1455121585-22659-2-git-send-email-ian.campbell@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Wed, Feb 10, 2016 at 04:26:25PM +0000, Ian Campbell wrote: > 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 Acked-by: Wei Liu > --- > 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 > -- > 2.1.4 >