From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: [PATCH] tools/libxc: Initialise parameters in map_p2m_list() for error paths Date: Thu, 7 Jan 2016 15:04:34 +0000 Message-ID: <20160107150434.GA1457@citrix.com> References: <1452178530-4450-1-git-send-email-andrew.cooper3@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: <1452178530-4450-1-git-send-email-andrew.cooper3@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: Andrew Cooper Cc: Juergen Gross , Wei Liu , Ian Jackson , Ian Campbell , Xen-devel List-Id: xen-devel@lists.xenproject.org On Thu, Jan 07, 2016 at 02:55:30PM +0000, Andrew Cooper wrote: > 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 > --- > 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); > -- > 2.1.4 >