From patchwork Wed Feb 10 16:26:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 8273221 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 213899F6DA for ; Wed, 10 Feb 2016 16:29:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B90B20396 for ; Wed, 10 Feb 2016 16:29:17 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80AB120386 for ; Wed, 10 Feb 2016 16:29:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aTXb7-00035G-5Z; Wed, 10 Feb 2016 16:26:33 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aTXb4-00034s-Tr for xen-devel@lists.xen.org; Wed, 10 Feb 2016 16:26:31 +0000 Received: from [85.158.143.35] by server-2.bemta-4.messagelabs.com id 4A/77-08977-6B46BB65; Wed, 10 Feb 2016 16:26:30 +0000 X-Env-Sender: prvs=841e7c5e8=Ian.Campbell@citrix.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1455121587!15041134!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 62144 invoked from network); 10 Feb 2016 16:26:29 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-9.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 10 Feb 2016 16:26:29 -0000 X-IronPort-AV: E=Sophos;i="5.22,426,1449532800"; d="scan'208";a="330862643" From: Ian Campbell To: , , Date: Wed, 10 Feb 2016 16:26:25 +0000 Message-ID: <1455121585-22659-2-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455121585-22659-1-git-send-email-ian.campbell@citrix.com> References: <1455121585-22659-1-git-send-email-ian.campbell@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Ian Campbell Subject: [Xen-devel] [PATCH 2/2] xenmon: initialise dummy array X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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