grub2/0198-grub-core-commands-acpi.c-grub_acpi_create_ebda-Don-.patch

58 lines
1.9 KiB
Diff
Raw Normal View History

2013-06-07 18:03:56 +00:00
From fa35f13018c92b66f4a68e1f32ede2b0327f993b Mon Sep 17 00:00:00 2001
From: Nickolai Zeldovich <nickolai@csail.mit.edu>
Date: Thu, 7 Mar 2013 08:52:29 +0100
Subject: [PATCH 198/482] * 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.
---
ChangeLog | 6 ++++++
grub-core/commands/acpi.c | 7 ++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ca3d603..5fb9b77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
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
OOM check.
* grub-core/normal/term.c (read_terminal_list): Likewise.
diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c
index 891e392..8000873 100644
--- a/grub-core/commands/acpi.c
+++ b/grub-core/commands/acpi.c
@@ -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;
--
2013-06-07 18:03:56 +00:00
1.8.2.1