mirror of https://gitlab.com/qemu-project/dtc.git
libfdt: Add FDT alignment check to fdt_check_header()
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 <trini@konsulko.com> Cc: Frank Rowand <frowand.list@gmail.com> Signed-off-by: Rob Herring <robh@kernel.org> Message-Id: <20210406190712.2118098-1-robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
a2def54799
commit
b07b62ee33
|
@ -90,6 +90,10 @@ int fdt_check_header(const void *fdt)
|
||||||
{
|
{
|
||||||
size_t hdrsize;
|
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)
|
if (fdt_magic(fdt) != FDT_MAGIC)
|
||||||
return -FDT_ERR_BADMAGIC;
|
return -FDT_ERR_BADMAGIC;
|
||||||
if (!can_assume(LATEST)) {
|
if (!can_assume(LATEST)) {
|
||||||
|
|
Loading…
Reference in New Issue