From 7dd06b1621579262e5be46d78ba1d63c8afe8040 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 25 Jul 2023 09:50:40 +0300 Subject: [PATCH] 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 --- 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 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; -- 2.39.5