diff --git a/boot/image-fit.c b/boot/image-fit.c index cccaa48f683..fce3a320eac 100644 --- a/boot/image-fit.c +++ b/boot/image-fit.c @@ -16,6 +16,9 @@ #include #include #include + +/* C11 standard function for aligned allocations */ +extern void *aligned_alloc(size_t alignment, size_t size); #else #include #include @@ -23,19 +26,21 @@ #include #include #include +#include #include #include #ifdef CONFIG_DM_HASH #include #include #endif +#define aligned_alloc(a, s) memalign((a), (s)) + DECLARE_GLOBAL_DATA_PTR; #endif /* !USE_HOSTCC*/ #include #include #include -#include #include #include @@ -2279,7 +2284,7 @@ int fit_image_load(struct bootm_headers *images, ulong addr, log_debug("decompressing image\n"); if (load == data) { - loadbuf = memalign(8, max_decomp_len); + loadbuf = aligned_alloc(8, max_decomp_len); load = map_to_sysmem(loadbuf); } else { loadbuf = map_sysmem(load, max_decomp_len); @@ -2293,7 +2298,7 @@ int fit_image_load(struct bootm_headers *images, ulong addr, len = load_end - load; } else if (load_op != FIT_LOAD_IGNORED && image_type == IH_TYPE_FLATDT && ((uintptr_t)buf & 7)) { - loadbuf = memalign(8, len); + loadbuf = aligned_alloc(8, len); load = map_to_sysmem(loadbuf); memcpy(loadbuf, buf, len); } else if (load != data) {