]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fdtdec: Fix boundary check
authorAtish Patra <atish.patra@wdc.com>
Tue, 21 Apr 2020 18:15:00 +0000 (11:15 -0700)
committerAndes <uboot@andestech.com>
Thu, 23 Apr 2020 02:14:16 +0000 (10:14 +0800)
In U-Boot, the reserved memory end address is considered as a inclusive
address. This notion is followed while adding a reserved memory node to
the DT.

For example:
end_address = start_address + size - 1

Follow the same notion and fix the end address computation while checking
for existing nodes.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
lib/fdtdec.c

index 9ecfa2a2d743c35a687003bc0098cdb12599d822..460f0d250b4d6414d920fdfdb18a943a8a025118 100644 (file)
@@ -1311,7 +1311,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
                        continue;
                }
 
-               if (addr == carveout->start && (addr + size) == carveout->end) {
+               if (addr == carveout->start && (addr + size - 1) ==
+                                               carveout->end) {
                        if (phandlep)
                                *phandlep = fdt_get_phandle(blob, node);
                        return 0;