lkml.org 
[lkml]   [2023]   [Jan]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] [PATCH] memblock: Fix return sizeless candidate on __memblock_find_range_top_down.
Date
__memblock_find_range_top_down can return start address of free region
which sizeless then user speicified.
To prevent the above case, add size check on candidate free region.

Signed-off-by: Levi Yun <ppbuk5246@gmail.com>
---
mm/memblock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index 511d4783dcf1..710e2ef8d67d 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -262,7 +262,7 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end,
continue;

cand = round_down(this_end - size, align);
- if (cand >= this_start)
+ if (cand >= this_start && this_end - cand >= size)
return cand;
}

--
2.35.1
\
 
 \ /
  Last update: 2023-03-26 23:26    [W:0.026 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site