[PATCH] addrmap: Fix off by one in addrmap_set_entry()

Dan Carpenter dan.carpenter at linaro.org
Tue Jul 25 08:50:40 CEST 2023


The > comparison needs to be changed to >= to prevent an out of bounds
write on th next line.

Signed-off-by: Dan Carpenter <dan.carpenter at linaro.org>
---
 lib/addr_map.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/addr_map.c b/lib/addr_map.c
index 9b3e0a544e47..86e932e4b561 100644
--- a/lib/addr_map.c
+++ b/lib/addr_map.c
@@ -59,7 +59,7 @@ void *addrmap_phys_to_virt(phys_addr_t paddr)
 void addrmap_set_entry(unsigned long vaddr, phys_addr_t paddr,
 			phys_size_t size, int idx)
 {
-	if (idx > CONFIG_SYS_NUM_ADDR_MAP)
+	if (idx >= CONFIG_SYS_NUM_ADDR_MAP)
 		return;
 
 	address_map[idx].vaddr = vaddr;
-- 
2.39.2



More information about the U-Boot mailing list