]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Don't try to malloc if grub_mm_base is 0
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 28 Aug 2010 09:32:49 +0000 (11:32 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 28 Aug 2010 09:32:49 +0000 (11:32 +0200)
grub-core/kern/mm.c

index fd4fde81ccb5efac203adebd5acfb00902bf6d2e..dec07bc1be68fda797772ad502e4a672324d26a5 100644 (file)
@@ -284,6 +284,9 @@ grub_memalign (grub_size_t align, grub_size_t size)
   grub_size_t n = ((size + GRUB_MM_ALIGN - 1) >> GRUB_MM_ALIGN_LOG2) + 1;
   int count = 0;
 
+  if (!grub_mm_base)
+    goto fail;
+
   align = (align >> GRUB_MM_ALIGN_LOG2);
   if (align == 0)
     align = 1;
@@ -318,6 +321,7 @@ grub_memalign (grub_size_t align, grub_size_t size)
       break;
     }
 
+ fail:
   grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
   return 0;
 }