]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
ARM/dom0: Avoid using a variable length array in make_memory_node()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 24 Sep 2018 13:00:02 +0000 (14:00 +0100)
committerJulien Grall <julien.grall@arm.com>
Mon, 24 Sep 2018 13:43:47 +0000 (14:43 +0100)
The reg[] array can have a maximum size of 8 in practice, so use the worst
case calculation rather than making it variable length.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
xen/arch/arm/domain_build.c

index 38e0de3b03fa2c849625c1db94958a4e613e4a50..ac8d4799f3ad9a02c9d6e1ca18101280805e588e 100644 (file)
@@ -539,9 +539,11 @@ static int __init make_memory_node(const struct domain *d,
     int res, i;
     int reg_size = addrcells + sizecells;
     int nr_cells = reg_size*kinfo->mem.nr_banks;
-    __be32 reg[nr_cells];
+    __be32 reg[NR_MEM_BANKS * 4 /* Worst case addrcells + sizecells */];
     __be32 *cells;
 
+    BUG_ON(nr_cells >= ARRAY_SIZE(reg));
+
     dt_dprintk("Create memory node (reg size %d, nr cells %d)\n",
                reg_size, nr_cells);