From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH 10/14] libxl: Check xc_maximum_ram_page for negative return values. Date: Wed, 18 Mar 2015 16:32:02 +0000 Message-ID: <1426696322.14291.77.camel@citrix.com> References: <1426520383-20855-1-git-send-email-konrad.wilk@oracle.com> <1426520383-20855-11-git-send-email-konrad.wilk@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YYH5p-0003co-38 for xen-devel@lists.xenproject.org; Wed, 18 Mar 2015 16:45:17 +0000 In-Reply-To: <1426520383-20855-11-git-send-email-konrad.wilk@oracle.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: Konrad Rzeszutek Wilk Cc: xen-devel@lists.xenproject.org, ian.jackson@eu.citrix.com, wei.liu2@citrix.com, stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org On Mon, 2015-03-16 at 11:39 -0400, Konrad Rzeszutek Wilk wrote: > Instead of assuming everything is always OK. > > Signed-off-by: Konrad Rzeszutek Wilk > --- > tools/libxc/xg_save_restore.h | 3 +++ > tools/misc/xen-mfndump.c | 2 +- > 2 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/tools/libxc/xg_save_restore.h b/tools/libxc/xg_save_restore.h > index bdd9009..6d26a0a 100644 > --- a/tools/libxc/xg_save_restore.h > +++ b/tools/libxc/xg_save_restore.h > @@ -313,6 +313,9 @@ static inline int get_platform_info(xc_interface *xch, uint32_t dom, > > *max_mfn = xc_maximum_ram_page(xch); > > + if (*max_mfn < 0) > + return 0; *max_mfn is unsigned, so the negative would have been lost already. Perhaps do the same sort of thing with a helper as the last patch? > + > *hvirt_start = xen_params.virt_start; > > if ( xc_domain_get_guest_width(xch, dom, guest_width) != 0) > diff --git a/tools/misc/xen-mfndump.c b/tools/misc/xen-mfndump.c > index 0761f6e..81ef448 100644 > --- a/tools/misc/xen-mfndump.c > +++ b/tools/misc/xen-mfndump.c > @@ -184,7 +184,7 @@ int dump_ptes_func(int argc, char *argv[]) > > /* Map M2P and obtain gpfn */ > max_mfn = xc_maximum_ram_page(xch); > - if ( (mfn > max_mfn) || > + if ( (max_mfn < 0 ) || (mfn > max_mfn) || Same here. > !(m2p_table = xc_map_m2p(xch, max_mfn, PROT_READ, NULL)) ) > { > xc_unmap_domain_meminfo(xch, &minfo);