* grub-core/kern/mm.c (grub_mm_init_region): Fix condition for

detecting too small regions.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-04-20 17:39:49 +02:00
parent ec2dd17919
commit fe4c3e7e67
2 changed files with 8 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2013-04-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/mm.c (grub_mm_init_region): Fix condition for
detecting too small regions.
2013-04-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/Makefile.core.def (legacycfg): Enable on EFI.

View file

@ -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;