lkml.org 
[lkml]   [2019]   [Aug]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] x86/kaslr: simplify the code in mem_avoid_memmap()
Date
If "i >= MAX_MEMMAP_REGIONS" already when entering mem_avoid_memmap(),
even without the return statement the loop will not run anyway. The only
time it needs to set "memmap_too_large = true" in this situation is
"memmap_too_large" is "false" currently. Hence, the code could be
simplified.

Signed-off-by: Qian Cai <cai@lca.pw>
---
arch/x86/boot/compressed/kaslr.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index 2e53c056ba20..35c6942fb95b 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -176,9 +176,6 @@ static void mem_avoid_memmap(char *str)
{
static int i;

- if (i >= MAX_MEMMAP_REGIONS)
- return;
-
while (str && (i < MAX_MEMMAP_REGIONS)) {
int rc;
unsigned long long start, size;
@@ -206,7 +203,7 @@ static void mem_avoid_memmap(char *str)
}

/* More than 4 memmaps, fail kaslr */
- if ((i >= MAX_MEMMAP_REGIONS) && str)
+ if (i >= MAX_MEMMAP_REGIONS && !memmap_too_large)
memmap_too_large = true;
}

--
1.8.3.1
\
 
 \ /
  Last update: 2019-08-22 16:26    [W:0.049 / U:0.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site