From: Ian Campbell Subject: Re: [PATCH v5 07/19] xen: arm: allocate dom0 memory separately from preparing the dtb Date: Thu, 14 Nov 2013 08:23:19 +0000 Message-ID: <1384417399.7059.21.camel@dagon.hellion.org.uk> References: <1384366234.29080.8.camel@kazak.uk.xensource.com> <1384366285-29277-7-git-send-email-ian.campbell@citrix.com> <5283F07D.2090404@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5283F07D.2090404@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Julien Grall Cc: stefano.stabellini@eu.citrix.com, tim@xen.org, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Wed, 2013-11-13 at 21:34 +0000, Julien Grall wrote: > > @@ -304,6 +292,46 @@ static int fdt_property_interrupts(void *fdt, gic_interrupt_t *intr, > > return res; > > } > > > > +static int make_memory_node(const struct domain *d, > > + void *fdt, > > + const struct kernel_info *kinfo) > > +{ > > + int res, i; > > + int nr_cells = XEN_FDT_NODE_REG_SIZE*kinfo->mem.nr_banks; > > What about xzalloc? I don't think it's safe to allocate an uncontrol > size (we don't know the size of nr_banks, even if now it's hardcoded). The stack is 8 pages (32k) which would be enough for 2048 memory banks of 16 bytes each. I think that is likely to be plenty, given that the function is called once at start of day and not from an especially deep call chain. The xzalloc in make_gic_node is unneccessary as well IMHO (even more so, since the size is at most 32 bytes or so) but I left it alone here. Ian.