If a single memory block is requested (GRUB_MM_ADD_REGION_CONSECUTIVE) then check early on whether the given block from the memory map is big enough to satisfy the request.
Signed-off-by: Stefan Berger <stef...@linux.ibm.com> Cc: Hari Bathini <hbath...@linux.ibm.com> Cc: Pavithra Prakash <pavra...@in.ibm.com> Cc: Michael Ellerman <m...@ellerman.id.au> Cc: Carolyn Scherrer <cpsch...@us.ibm.com> Cc: Mahesh Salgaonkar <mah...@linux.ibm.com> Cc: Sourabh Jain <sourabhj...@linux.ibm.com> --- grub-core/kern/ieee1275/init.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c index e09db4192..a0ce9d55e 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c @@ -328,6 +328,10 @@ regions_claim (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, if (type != GRUB_MEMORY_AVAILABLE) return 0; + /* If a specific size was requested: is this chunk big enough? */ + if (rcr->flags & GRUB_MM_ADD_REGION_CONSECUTIVE && len < rcr->total) + return 0; + /* Do not consider memory beyond 4GB */ if (addr > 0xffffffffULL) return 0; -- 2.25.1 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel