Message ID | 20191008011501.21038-2-sstabellini@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fixes for make_[memory/cpu]_node | expand |
On 10/8/19 2:15 AM, Stefano Stabellini wrote: > Call make_memory_node for reserved_memory only if we actually have any > reserved_memory regions to handle. > > Add a check in make_memory_node to return an error if it has been called > with no memory banks as argument. > > Fixes: 248faa637d2 (xen/arm: add reserved-memory regions to the dom0 memory node) > Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com> Acked-by: Julien Grall <julien.grall@arm.com> Cheers,
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 60923a7051..ea01aada0b 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -650,6 +650,8 @@ static int __init make_memory_node(const struct domain *d, __be32 *cells; BUG_ON(nr_cells >= ARRAY_SIZE(reg)); + if ( mem->nr_banks == 0 ) + return -ENOENT; dt_dprintk("Create memory node (reg size %d, nr cells %d)\n", reg_size, nr_cells); @@ -1540,10 +1542,13 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo, * Create a second memory node to store the ranges covering * reserved-memory regions. */ - res = make_memory_node(d, kinfo->fdt, addrcells, sizecells, - &bootinfo.reserved_mem); - if ( res ) - return res; + if ( bootinfo.reserved_mem.nr_banks > 0 ) + { + res = make_memory_node(d, kinfo->fdt, addrcells, sizecells, + &bootinfo.reserved_mem); + if ( res ) + return res; + } } res = fdt_end_node(kinfo->fdt);
Call make_memory_node for reserved_memory only if we actually have any reserved_memory regions to handle. Add a check in make_memory_node to return an error if it has been called with no memory banks as argument. Fixes: 248faa637d2 (xen/arm: add reserved-memory regions to the dom0 memory node) Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com> --- Changes in v2: - patch added --- xen/arch/arm/domain_build.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)