]> git.ipfire.org Git - thirdparty/u-boot.git/commit
image: fit: Apply overlays using aligned writable FDT copies
authorJames Hilliard <james.hilliard1@gmail.com>
Thu, 12 Feb 2026 21:34:09 +0000 (14:34 -0700)
committerTom Rini <trini@konsulko.com>
Mon, 16 Feb 2026 17:52:01 +0000 (11:52 -0600)
commit5ebf0c55a23ad740da1ec191ac157c490f207e0f
treed29fce038ef5b032ec838776572439597b9e3866
parenta79edd52a80ac346ac605362f1a61a6062b2aec8
image: fit: Apply overlays using aligned writable FDT copies

libfdt expects FDT/DTO blobs to be 8-byte aligned. When loading the
base FDT or overlays from a FIT, the mapped buffer may be unaligned,
which can break fdt_open_into() on strict-alignment architectures.

boot_get_fdt_fit() relocates the base FDT with boot_relocate_fdt()
before applying overlays. That uses the bootm memory map and can
overlap with the FIT buffer when the FIT is loaded into RAM,
corrupting data needed to load the kernel and ramdisk.

Allocate writable, 8-byte aligned copies of the base FDT and overlays
with memalign() and fdt_open_into(). Grow the base buffer as needed,
apply overlays to it and pack the final tree. Free each temporary
overlay copy after application and check fdt_pack() errors.

Fixes: 8fbcc0e0e839 ("boot: Assure FDT is always 8-byte aligned")
Fixes: 881f0b77dc8c ("image: apply FDTOs on FDT image node")
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Cc: Jamie Gibbons <Jamie.Gibbons@microchip.com>
Reviewed-by: Marek Vasut <marek.vasut@mailbox.org>
boot/image-fit.c