From ae7b1135efc6a9c8f6ba6008b4964ad5423290d9 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Wed, 21 Oct 2020 12:11:36 +0900 Subject: [PATCH] bootm: fix wrong conditions about images overlap It doesn't need to consider start byte address. If ramdisk size is 0x800000 and start address is 0x2700000, then it's used until 0x02efffff, not 0x02f00000. But it's detected to overlapt RD image, when kernel start address is 0x02f00000. Because it's doing wrong calculation about rd_len. This patch fixed wrong calculation address position when check condition. In addition, it needs to check one more condition about overlapping entire area. Fixes: commit fbde7589ce30 ("common: bootm: add checks to verify if ramdisk / fdtimage overlaps OS image") Signed-off-by: Jaehoon Chung --- common/bootm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/bootm.c b/common/bootm.c index b337749..167eea4 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -256,9 +256,11 @@ int bootm_find_images(int flag, int argc, char *const argv[], ulong start, /* check if ramdisk overlaps OS image */ if (images.rd_start && (((ulong)images.rd_start >= start && - (ulong)images.rd_start <= start + size) || - ((ulong)images.rd_end >= start && - (ulong)images.rd_end <= start + size))) { + (ulong)images.rd_start < start + size) || + ((ulong)images.rd_end > start && + (ulong)images.rd_end <= start + size) || + ((ulong)images.rd_start < start && + (ulong)images.rd_end >= start + size))) { printf("ERROR: RD image overlaps OS image (OS=0x%lx..0x%lx)\n", start, start + size); return 1; -- 2.7.4