[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] tools/libxc: Initialise parameters in map_p2m_list() for error paths



On Thu, 2016-01-07 at 14:55 +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.

Isn't the issue the malloc goto err path before the loop? Looks like that
should have the error behaviour from the earlier half of the function
rather than the latter.

There might also be a path if ctx->x86_pv.levels == 0, in which case the
loop will never run, that's the sort of thing which could be checked (or
even perhaps asserted) on entry to the function.

> Initialise the parameters to safe default to make the function more
> robust.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> ---
> CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
> CC: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
> CC: Wei Liu <wei.liu2@xxxxxxxxxx>
> CC: Juergen Gross <jgross@xxxxxxxx>
> ---
> Â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);

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.