From: Oleksandr Andrushchenko Date: Fri, 19 Jun 2020 08:22:18 +0000 (+0300) Subject: common/board_f: Respect original FDT size while relocating X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=53007fc1eb892cd67af97c545eb3461020cc3885;p=u-boot.git common/board_f: Respect original FDT size while relocating 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 --- diff --git a/common/board_f.c b/common/board_f.c index dcad551ae4..b61036577a 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