]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
addrmap: Fix off by one in addrmap_set_entry()
authorDan Carpenter <dan.carpenter@linaro.org>
Tue, 25 Jul 2023 06:50:40 +0000 (09:50 +0300)
committerTom Rini <trini@konsulko.com>
Mon, 30 Oct 2023 19:32:49 +0000 (15:32 -0400)
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@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
lib/addr_map.c

index 9b3e0a544e478e00c4ec8cdc09ab2fce0d9dc2dc..86e932e4b561f24ed4b78098b480833e3bf67a76 100644 (file)
@@ -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;