From fe4c3e7e670d45d2b5e1624e256f9cd09bbecf34 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 20 Apr 2013 17:39:49 +0200 Subject: [PATCH] * grub-core/kern/mm.c (grub_mm_init_region): Fix condition for detecting too small regions. --- ChangeLog | 5 +++++ grub-core/kern/mm.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b2e3cccac..2a4264cf0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-04-20 Vladimir Serbinenko + + * grub-core/kern/mm.c (grub_mm_init_region): Fix condition for + detecting too small regions. + 2013-04-20 Vladimir Serbinenko * grub-core/Makefile.core.def (legacycfg): Enable on EFI. diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c index d8690916c..959c3bab1 100644 --- a/grub-core/kern/mm.c +++ b/grub-core/kern/mm.c @@ -140,12 +140,13 @@ grub_mm_init_region (void *addr, grub_size_t size) /* Allocate a region from the head. */ r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN); - size -= (char *) r - (char *) addr + sizeof (*r); /* If this region is too small, ignore it. */ - if (size < GRUB_MM_ALIGN) + if (size < GRUB_MM_ALIGN + (char *) r - (char *) addr + sizeof (*r)) return; + size -= (char *) r - (char *) addr + sizeof (*r); + h = (grub_mm_header_t) (r + 1); h->next = h; h->magic = GRUB_MM_FREE_MAGIC;