From: Dan Carpenter Date: Tue, 25 Jul 2023 06:50:40 +0000 (+0300) Subject: addrmap: Fix off by one in addrmap_set_entry() X-Git-Url: http://git.dujemihanovic.xyz/img/static/gitweb.css?a=commitdiff_plain;h=7dd06b1621579262e5be46d78ba1d63c8afe8040;p=u-boot.git addrmap: Fix off by one in addrmap_set_entry() The > comparison needs to be changed to >= to prevent an out of bounds write on th next line. Signed-off-by: Dan Carpenter Reviewed-by: Simon Glass --- diff --git a/lib/addr_map.c b/lib/addr_map.c index 9b3e0a544e..86e932e4b5 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;