37 lines
1.3 KiB
Diff
37 lines
1.3 KiB
Diff
|
|
From e6b133311a7a5a618b48c6f38e3c3bb9e9a395c9 Mon Sep 17 00:00:00 2001
|
||
|
|
From: eillon <yezhenyu2@huawei.com>
|
||
|
|
Date: Mon, 14 Feb 2022 15:35:28 +0800
|
||
|
|
Subject: [PATCH] seabios: add check to avoid dereference NULL pointer
|
||
|
|
|
||
|
|
alloc_find_lowest() may return NULL, check it.
|
||
|
|
|
||
|
|
Signed-off-by: eillon <yezhenyu2@huawei.com>
|
||
|
|
---
|
||
|
|
roms/seabios/src/malloc.c | 10 ++++++----
|
||
|
|
1 file changed, 6 insertions(+), 4 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/roms/seabios/src/malloc.c b/roms/seabios/src/malloc.c
|
||
|
|
index 5827a6523..99fa3b7e0 100644
|
||
|
|
--- a/roms/seabios/src/malloc.c
|
||
|
|
+++ b/roms/seabios/src/malloc.c
|
||
|
|
@@ -544,10 +544,12 @@ malloc_prepboot(void)
|
||
|
|
|
||
|
|
// Clear unused f-seg ram.
|
||
|
|
struct allocinfo_s *info = alloc_find_lowest(&ZoneFSeg);
|
||
|
|
- u32 size = info->range_end - info->range_start;
|
||
|
|
- memset(memremap(info->range_start, size), 0, size);
|
||
|
|
- dprintf(1, "Space available for UMB: %x-%x, %x-%x\n"
|
||
|
|
- , RomEnd, base, info->range_start, info->range_end);
|
||
|
|
+ if (info) {
|
||
|
|
+ u32 size = info->range_end - info->range_start;
|
||
|
|
+ memset(memremap(info->range_start, size), 0, size);
|
||
|
|
+ dprintf(1, "Space available for UMB: %x-%x, %x-%x\n"
|
||
|
|
+ , RomEnd, base, info->range_start, info->range_end);
|
||
|
|
+ }
|
||
|
|
|
||
|
|
// We should not give back unused high ram, to support some special
|
||
|
|
// guest OS, like oracle linux series.
|
||
|
|
--
|
||
|
|
2.27.0
|
||
|
|
|