libfdt: fdt_check_full: Handle FDT_NOP when FDT_END is expected
Some checks failed
Build test / build-make (alpine) (push) Has been cancelled
Build test / build-make (archlinux) (push) Has been cancelled
Build test / build-make (fedora) (push) Has been cancelled
Build test / build-make (ubuntu) (push) Has been cancelled
Build test / build-meson (alpine) (push) Has been cancelled
Build test / build-meson (archlinux) (push) Has been cancelled
Build test / build-meson (fedora) (push) Has been cancelled
Build test / build-meson (ubuntu) (push) Has been cancelled
Build test / clang64 (push) Has been cancelled
Build test / mingw32 (push) Has been cancelled
Build test / mingw64 (push) Has been cancelled
Build test / ucrt64 (push) Has been cancelled

fdt_check_full() makes the assumption that a FDT_END tag is present
immediately after the FDT_END_NODE tag related to the root node.

This assumption is not correct. Indeed, FDT_NOP tags can be present
between this FDT_END_NODE tag and the FDT_END tag.

Handle those possible FDT_NOP tags.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Message-ID: <20260210173349.636766-8-herve.codina@bootlin.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Herve Codina 2026-02-10 18:33:35 +01:00 committed by David Gibson
parent 5976c4a660
commit caf7465c5d

View file

@ -43,7 +43,7 @@ int fdt_check_full(const void *fdt, size_t bufsize)
return nextoffset;
/* If we see two root nodes, something is wrong */
if (expect_end && tag != FDT_END)
if (expect_end && tag != FDT_END && tag != FDT_NOP)
return -FDT_ERR_BADSTRUCTURE;
switch (tag) {