xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>
Cc: Juergen Gross <jgross@suse.com>, Wei Liu <wei.liu2@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: Re: [PATCH] tools/libxc: Initialise parameters in map_p2m_list() for error paths
Date: Thu, 7 Jan 2016 15:35:56 +0000	[thread overview]
Message-ID: <1452180956.21055.251.camel@citrix.com> (raw)
In-Reply-To: <568E8334.9040405@citrix.com>

On Thu, 2016-01-07 at 15:24 +0000, Andrew Cooper wrote:
> On 07/01/16 15:06, Ian Campbell wrote:
> > 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.
> 
> So it is - I missed that one when looking the options.
> 
> > 
> > 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.
> 
> I don't think asserting details like this is a scalable options.  Also,
> it doesn't help the compilation error if someone ends up disabling
> assert() by playing with NDEBUG.

It could be an error return instead (which is what I meant to suggest
without the parenthetical).

> All that is needed is an adjustment to the commit message IMO:

I can live with this.

> 
> ---8<---
> tools/libxc: Initialise parameters in map_p2m_list() for error paths
> 
> 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.
> 
> Indeed, the malloc() failure path would end using 'ptes' while
> uninitialised.  Initialise the parameters to safe defaults.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> 

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

  reply	other threads:[~2016-01-07 15:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-07 14:55 [PATCH] tools/libxc: Initialise parameters in map_p2m_list() for error paths Andrew Cooper
2016-01-07 15:04 ` Wei Liu
2016-01-07 15:06 ` Ian Campbell
2016-01-07 15:19   ` Juergen Gross
2016-01-07 15:24   ` Andrew Cooper
2016-01-07 15:35     ` Ian Campbell [this message]
2016-01-07 15:06 ` Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452180956.21055.251.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jgross@suse.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).