diff --git a/drivers/renesas/common/io/io_rcar.c b/drivers/renesas/common/io/io_rcar.c index 9b29a5be81..21ed411137 100644 --- a/drivers/renesas/common/io/io_rcar.c +++ b/drivers/renesas/common/io/io_rcar.c @@ -335,13 +335,18 @@ static int32_t check_load_area(uintptr_t dst, uintptr_t len) * 2. check: * | IMAGE n | * | IMAGE n+1 | + * 3. check: + * | IMAGE n | + * | IMAGE n+1 | * * */ - if (((dst > addr_loaded[n].dest) && - (dst < addr_loaded[n].dest + addr_loaded[n].length)) || - (((dst < addr_loaded[n].dest) && - (dst + len)) > addr_loaded[n].dest)) { - ERROR("BL2: image is inside a previous image area.\n"); + if (((dst >= addr_loaded[n].dest) && + (dst <= addr_loaded[n].dest + addr_loaded[n].length)) || + ((dst + len >= addr_loaded[n].dest) && + (dst + len <= addr_loaded[n].dest + addr_loaded[n].length)) || + ((dst <= addr_loaded[n].dest) && + (dst + len >= addr_loaded[n].dest + addr_loaded[n].length))) { + ERROR("BL2: next image overlap a previous image area.\n"); result = IO_FAIL; } }