diff mbox series

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

Message ID 20200421181504.415822-3-atish.patra@wdc.com
State Superseded
Headers show
Series RISC-V DT related fixes for reserved memory & UEFI | expand

Commit Message

Atish Patra April 21, 2020, 6:15 p.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>
Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
---
 lib/fdtdec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Bin Meng April 22, 2020, 5:20 a.m. UTC | #1
On Wed, Apr 22, 2020 at 2:15 AM Atish Patra <atish.patra at wdc.com> wrote:
>
> 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>
> Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
> ---
>  lib/fdtdec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>

Tested-by: Bin Meng <bmeng.cn at gmail.com>
diff mbox series

Patch

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 9ecfa2a2d743..460f0d250b4d 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;