From patchwork Thu Jan 7 14:55:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 7977901 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 429BF9F3E6 for ; Thu, 7 Jan 2016 14:58:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 701982013D for ; Thu, 7 Jan 2016 14:58:40 +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 9BE4A2012D for ; Thu, 7 Jan 2016 14:58:39 +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 1aHByX-0005Zc-3i; Thu, 07 Jan 2016 14:55:41 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aHByV-0005ZX-Az for xen-devel@lists.xen.org; Thu, 07 Jan 2016 14:55:39 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id DF/AC-23747-A6C7E865; Thu, 07 Jan 2016 14:55:38 +0000 X-Env-Sender: prvs=8071b990d=Andrew.Cooper3@citrix.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1452178533!13948118!1 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 3316 invoked from network); 7 Jan 2016 14:55:35 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-13.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 7 Jan 2016 14:55:35 -0000 X-IronPort-AV: E=Sophos;i="5.20,533,1444694400"; d="scan'208";a="323445920" From: Andrew Cooper To: Xen-devel Date: Thu, 7 Jan 2016 14:55:30 +0000 Message-ID: <1452178530-4450-1-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-DLP: MIA2 Cc: Juergen Gross , Andrew Cooper , Ian Jackson , Ian Campbell , Wei Liu Subject: [Xen-devel] [PATCH] tools/libxc: Initialise parameters in map_p2m_list() for error paths 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 c/s 7bf7458 "libxc: support of linear p2m list for migration of pv-domains" breaks compilation on CentOS 7 because of 'ptes' being possibly uninitialised after the 'err:' label. The migration will fail early for conditions which would cause the for() loop not to run, but the compiler doesn't know this. Initialise the parameters to safe default to make the function more robust. Signed-off-by: Andrew Cooper Acked-by: Wei Liu Acked-by: Juergen Gross Signed-off-by: Andrew Cooper --- CC: Ian Campbell CC: Ian Jackson CC: Wei Liu CC: Juergen Gross --- tools/libxc/xc_sr_save_x86_pv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_pv.c index 4deb58f..ab4bbe0 100644 --- a/tools/libxc/xc_sr_save_x86_pv.c +++ b/tools/libxc/xc_sr_save_x86_pv.c @@ -316,9 +316,9 @@ static int map_p2m_list(struct xc_sr_context *ctx, uint64_t p2m_cr3) xc_interface *xch = ctx->xch; xen_vaddr_t p2m_vaddr, p2m_end, mask, off; xen_pfn_t p2m_mfn, mfn, saved_mfn, max_pfn; - uint64_t *ptes; + uint64_t *ptes = NULL; xen_pfn_t *mfns; - unsigned fpp, n_pages, level, shift, idx_start, idx_end, idx, saved_idx; + unsigned fpp, n_pages = 0, level, shift, idx_start, idx_end, idx, saved_idx; int rc = -1; p2m_mfn = cr3_to_mfn(ctx, p2m_cr3);