]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/commands/acpi.c (grub_acpi_create_ebda): Don't
authorNickolai Zeldovich <nickolai@csail.mit.edu>
Thu, 7 Mar 2013 07:52:29 +0000 (08:52 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 7 Mar 2013 07:52:29 +0000 (08:52 +0100)
dereference null pointer. While the code is technically correct, gcc
may eliminate a null check if pointer is already dereferenced.

ChangeLog
grub-core/commands/acpi.c

index ca3d603d9445525c5c10a2268a33e594dff9f885..5fb9b77ab8ff27efdf3e93114e3e3dca18c1c63b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-03-07  Nickolai Zeldovich <nickolai@csail.mit.edu>
+
+       * grub-core/commands/acpi.c (grub_acpi_create_ebda): Don't
+       dereference null pointer. While the code is technically correct, gcc
+       may eliminate a null check if pointer is already dereferenced.
+
 2013-03-07  Nickolai Zeldovich <nickolai@csail.mit.edu>
 
        * grub-core/normal/crypto.c (read_crypto_list): Fix incorrect
index 891e392a590fc85587fe75b1aa38e887a967bbd4..80008731168a0bf8f976dfa42122e99a5bfcbbde 100644 (file)
@@ -171,7 +171,7 @@ grub_acpi_create_ebda (void)
   struct grub_acpi_create_ebda_ctx ctx = {
     .highestlow = 0
   };
-  int ebda_kb_len;
+  int ebda_kb_len = 0;
   int mmapregion = 0;
   grub_uint8_t *ebda, *v1inebda = 0, *v2inebda = 0;
   grub_uint8_t *targetebda, *target;
@@ -179,8 +179,9 @@ grub_acpi_create_ebda (void)
   struct grub_acpi_rsdp_v20 *v2;
 
   ebda = (grub_uint8_t *) (grub_addr_t) ((*((grub_uint16_t *)0x40e)) << 4);
-  ebda_kb_len = *(grub_uint16_t *) ebda;
-  if (! ebda || ebda_kb_len > 16)
+  if (ebda)
+    ebda_kb_len = *(grub_uint16_t *) ebda;
+  if (ebda_kb_len > 16)
     ebda_kb_len = 0;
   ctx.ebda_len = (ebda_kb_len + 1) << 10;