From: Wei Liu Subject: Re: [v3][PATCH 13/16] tools/libxl: detect and avoid conflicts with RDM Date: Mon, 15 Jun 2015 16:01:07 +0100 Message-ID: <20150615150107.GC10177@zion.uk.xensource.com> References: <1433985325-16676-1-git-send-email-tiejun.chen@intel.com> <1433985325-16676-14-git-send-email-tiejun.chen@intel.com> <20150612163944.GZ14606@zion.uk.xensource.com> <557E2F79.7050502@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <557E2F79.7050502@intel.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: "Chen, Tiejun" Cc: kevin.tian@intel.com, Wei Liu , ian.campbell@citrix.com, andrew.cooper3@citrix.com, tim@xen.org, xen-devel@lists.xen.org, stefano.stabellini@citrix.com, jbeulich@suse.com, yang.z.zhang@intel.com, Ian.Jackson@eu.citrix.com List-Id: xen-devel@lists.xenproject.org On Mon, Jun 15, 2015 at 09:50:49AM +0800, Chen, Tiejun wrote: [...] > >>+ uint32_t flag, > >>+ uint16_t seg, > >>+ uint8_t bus, > >>+ uint8_t devfn, > >>+ unsigned int *nr_entries) > >>+{ > >>+ struct xen_reserved_device_memory *xrdm; > >>+ int rc; > >>+ > >>+ rc = xc_reserved_device_memory_map(CTX->xch, flag, seg, bus, devfn, > >>+ NULL, nr_entries); > > > >xc_reserved_device_memory_map dereferences nr_entries. You need to make > >sure there is no garbage value in nr_entries. I.e. you need to > >initialise nr_entries to 0 before passing it in. > > Sure, so what about this? > > /* > * We really can't presume how many entries we can get in advance. > */ > if (*nr_entries) > *nr_entries = 0; > You might just unconditionally set *nr_entries to 0. Wei.