From patchwork Fri Jun 19 08:22:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 242669 List-Id: U-Boot discussion From: andr2000 at gmail.com (Oleksandr Andrushchenko) Date: Fri, 19 Jun 2020 11:22:18 +0300 Subject: [PATCH] common/board_f: Respect original FDT size while relocating Message-ID: <20200619082218.656-1-andr2000@gmail.com> From: Oleksandr Andrushchenko While relocating FDT we reserve some memory for the new FDT and set the size of the FDT with that respect. But FDT may be placed at the end of the RAM leading to memory access beyond it. Fix this by copying exact FDT size bytes, not the reserved size. Signed-off-by: Oleksandr Andrushchenko Reviewed-by: Simon Glass --- common/board_f.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/board_f.c b/common/board_f.c index 01194eaa0e4d..aa1285e94999 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -670,7 +670,7 @@ static int reloc_fdt(void) if (gd->flags & GD_FLG_SKIP_RELOC) return 0; if (gd->new_fdt) { - memcpy(gd->new_fdt, gd->fdt_blob, gd->fdt_size); + memcpy(gd->new_fdt, gd->fdt_blob, fdt_totalsize(gd->fdt_blob)); gd->fdt_blob = gd->new_fdt; } #endif