From: Rob Herring <r...@kernel.org> Only checking the FDT alignment in fdt_ro_probe_() means that fdt_check_header() can pass, but then subsequent API calls fail on alignment checks. Let's add an alignment check to fdt_check_header() so alignment errors are found up front.
Cc: Tom Rini <tr...@konsulko.com> Cc: Frank Rowand <frowand.l...@gmail.com> Signed-off-by: Rob Herring <r...@kernel.org> Message-Id: <20210406190712.2118098-1-r...@kernel.org> Signed-off-by: David Gibson <da...@gibson.dropbear.id.au> --- cpukit/dtc/libfdt/fdt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpukit/dtc/libfdt/fdt.c b/cpukit/dtc/libfdt/fdt.c index 3e893073da..9fe7cf4b74 100644 --- a/cpukit/dtc/libfdt/fdt.c +++ b/cpukit/dtc/libfdt/fdt.c @@ -90,6 +90,10 @@ int fdt_check_header(const void *fdt) { size_t hdrsize; + /* The device tree must be at an 8-byte aligned address */ + if ((uintptr_t)fdt & 7) + return -FDT_ERR_ALIGNMENT; + if (fdt_magic(fdt) != FDT_MAGIC) return -FDT_ERR_BADMAGIC; if (!can_assume(LATEST)) { -- 2.31.1 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel