diff mbox series

[v4,2/6] fdtdec: Fix boundary check

Message ID 20200324041650.280302-3-atish.patra@wdc.com
State Accepted
Commit f614753c4b91bc3b56809773aeb17da10f1231a5
Headers show
Series DT related fixes for RISC-V UEFI | expand

Commit Message

Atish Patra March 24, 2020, 4:16 a.m. UTC
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 at wdc.com>
---
 lib/fdtdec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index eb11fc898e30..07ba9f5c97e9 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -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;