The end parameter received by kimage_is_destination_range() should be the
last valid byte address of the target memory segment plus 1. However, in
the locate_mem_hole_bottom_up() and locate_mem_hole_top_down() functions,
the corresponding value passed to kimage_is_destination_range() is the last
valid byte address of the target memory segment, which is 1 less. Fix it.

Signed-off-by: Yuntao Wang <[email protected]>
---
 kernel/kexec_file.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index f9a419cd22d4..26be070d3bdd 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -435,13 +435,12 @@ static int locate_mem_hole_top_down(unsigned long start, 
unsigned long end,
                if (temp_start < start || temp_start < kbuf->buf_min)
                        return 0;
 
-               temp_end = temp_start + kbuf->memsz - 1;
-
                /*
                 * Make sure this does not conflict with any of existing
                 * segments
                 */
-               if (kimage_is_destination_range(image, temp_start, temp_end)) {
+               if (kimage_is_destination_range(image, temp_start,
+                                               temp_start + kbuf->memsz)) {
                        temp_start = temp_start - PAGE_SIZE;
                        continue;
                }
@@ -475,7 +474,7 @@ static int locate_mem_hole_bottom_up(unsigned long start, 
unsigned long end,
                 * Make sure this does not conflict with any of existing
                 * segments
                 */
-               if (kimage_is_destination_range(image, temp_start, temp_end)) {
+               if (kimage_is_destination_range(image, temp_start, temp_end + 
1)) {
                        temp_start = temp_start + PAGE_SIZE;
                        continue;
                }
-- 
2.43.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Reply via email to