summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2020-10-27 09:17:54 +0300
committerSascha Hauer <s.hauer@pengutronix.de>2020-10-28 09:24:41 +0100
commitca4292daf6a4d15b6e6ce0f610697e75df516533 (patch)
tree8c938ad447e62e42683c034bfbd26eb1b730433d
parent8ac84eedb283788584b90f07a1026377fa6a24fa (diff)
downloadbarebox-master.tar.gz
ARM: bootm: Add lower bound check of kernel in SDRAMHEADmaster
In get_kernel_addresses(), we add the lower bound check of kernel position. Kernel address cannot be lower than SDRAM start. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/lib32/bootm.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
index ad807fb..28a645a 100644
--- a/arch/arm/lib32/bootm.c
+++ b/arch/arm/lib32/bootm.c
@@ -114,10 +114,11 @@ static int get_kernel_addresses(size_t image_size,
kaddr = mem_start + image_decomp_size;
/*
- * Make sure we do not place the image past the end of the
+ * Make sure we do not place the image outside of the
* available memory.
*/
- if (kaddr + image_size + spacing >= mem_end)
+ if (((kaddr + image_size + spacing) > mem_end) &&
+ ((mem_end - image_size - spacing) >= mem_start))
kaddr = mem_end - image_size - spacing;
*load_address = PAGE_ALIGN_DOWN(kaddr);