From patchwork Thu May 28 08:46:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 246771 List-Id: U-Boot discussion From: bmeng.cn at gmail.com (Bin Meng) Date: Thu, 28 May 2020 01:46:43 -0700 Subject: [PATCH v2 2/3] riscv: Expand the DT size before copy reserved memory node In-Reply-To: <1590655604-13704-1-git-send-email-bmeng.cn@gmail.com> References: <1590655604-13704-1-git-send-email-bmeng.cn@gmail.com> Message-ID: <1590655604-13704-2-git-send-email-bmeng.cn@gmail.com> From: Bin Meng The FDT blob might not have sufficient space to hold a copy of reserved memory node. Expand it before the copy. Reported-by: Rick Chen Signed-off-by: Bin Meng --- arch/riscv/lib/fdt_fixup.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c index 5f523f0..1290a64 100644 --- a/arch/riscv/lib/fdt_fixup.c +++ b/arch/riscv/lib/fdt_fixup.c @@ -41,6 +41,12 @@ int riscv_fdt_copy_resv_mem_node(const void *src, void *dst) return 0; } + err = fdt_open_into(dst, dst, fdt_totalsize(dst) + 32); + if (err < 0) { + printf("Device Tree can't be expanded to accommodate new node"); + return err; + } + fdt_for_each_subnode(node, src, offset) { name = fdt_get_name(src, node, NULL);