From 3b01518e688d7c7d9d46ac41b11dd2b0c4788775 Mon Sep 17 00:00:00 2001 From: Justin Covell Date: Mon, 28 Dec 2020 20:17:49 -0800 Subject: Set last_comp_version correctly in new dtb and fix potential version issues in fdt_open_into Changes in v3: - Remove noop version sets - Set version correctly on loaded fdt in fdt_open_into Fixes: f1879e1a50eb ("Add limited read-only support for older (V2 and V3) device tree to libfdt.") Signed-off-by: Justin Covell Message-Id: <20201229041749.2187-1-jujugoboom@gmail.com> Signed-off-by: David Gibson --- libfdt/fdt_rw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libfdt/fdt_rw.c') diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c index 68887b9..f13458d 100644 --- a/libfdt/fdt_rw.c +++ b/libfdt/fdt_rw.c @@ -428,12 +428,14 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize) if (can_assume(LATEST) || fdt_version(fdt) >= 17) { struct_size = fdt_size_dt_struct(fdt); - } else { + } else if (fdt_version(fdt) == 16) { struct_size = 0; while (fdt_next_tag(fdt, struct_size, &struct_size) != FDT_END) ; if (struct_size < 0) return struct_size; + } else { + return -FDT_ERR_BADVERSION; } if (can_assume(LIBFDT_ORDER) || -- cgit v1.2.3-59-g8ed1b