From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Chen, Tiejun" Subject: Re: [v3][PATCH 13/16] tools/libxl: detect and avoid conflicts with RDM Date: Tue, 16 Jun 2015 09:44:10 +0800 Message-ID: <557F7F6A.4030805@intel.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> <20150615150107.GC10177@zion.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20150615150107.GC10177@zion.uk.xensource.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: Wei Liu Cc: kevin.tian@intel.com, 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 2015/6/15 23:01, Wei Liu wrote: > 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. > Okay. Thanks Tiejun