* kern/mm.c (grub_mm_init_region): Check for region size after aligning
pointers.
This commit is contained in:
parent
2589383147
commit
9b058d5291
2 changed files with 10 additions and 6 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* kern/mm.c (grub_mm_init_region): Check for region size after aligning
|
||||||
|
pointers.
|
||||||
|
|
||||||
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* kern/mm.c (grub_real_malloc): Fix size calculation when extra == 0.
|
* kern/mm.c (grub_real_malloc): Fix size calculation when extra == 0.
|
||||||
|
|
11
kern/mm.c
11
kern/mm.c
|
@ -148,15 +148,14 @@ grub_mm_init_region (void *addr, grub_size_t size)
|
||||||
grub_printf ("Using memory for heap: start=%p, end=%p\n", addr, addr + (unsigned int) size);
|
grub_printf ("Using memory for heap: start=%p, end=%p\n", addr, addr + (unsigned int) size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If this region is too small, ignore it. */
|
|
||||||
if (size < GRUB_MM_ALIGN * 2)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Allocate a region from the head. */
|
/* Allocate a region from the head. */
|
||||||
r = (grub_mm_region_t) (((grub_addr_t) addr + GRUB_MM_ALIGN - 1)
|
r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN);
|
||||||
& (~(GRUB_MM_ALIGN - 1)));
|
|
||||||
size -= (char *) r - (char *) addr + sizeof (*r);
|
size -= (char *) r - (char *) addr + sizeof (*r);
|
||||||
|
|
||||||
|
/* If this region is too small, ignore it. */
|
||||||
|
if (size < GRUB_MM_ALIGN)
|
||||||
|
return;
|
||||||
|
|
||||||
h = (grub_mm_header_t) ((char *) r + GRUB_MM_ALIGN);
|
h = (grub_mm_header_t) ((char *) r + GRUB_MM_ALIGN);
|
||||||
h->next = h;
|
h->next = h;
|
||||||
h->magic = GRUB_MM_FREE_MAGIC;
|
h->magic = GRUB_MM_FREE_MAGIC;
|
||||||
|
|
Loading…
Reference in a new issue