In case MULTI_DTB_FIT_GZIP is enabled, fdtdec_setup() does uncompress the compressed DTs in uncompress_blob() using gunzip(), which invokes malloc() internally. The early simple malloc is initialized in board_f initf_malloc() call, which sets up the early simple malloc limit and offset pointer in global data. Currently, the initf_malloc() is called after fdtdec_setup(), which leads to malloc failure in fdtdec_setup() during the gzip decompression, because the early simple malloc is not initialized yet.
Call initf_malloc() before fdtdec_setup() to assure fdtdec_setup() can use malloc() during gzip decompression of the DTs. The impact of this change on boot time is negligible, because the initf_malloc() only assigns two fields in global data. Signed-off-by: Marek Vasut <[email protected]> --- Cc: Ilias Apalodimas <[email protected]> Cc: Simon Glass <[email protected]> Cc: Tom Rini <[email protected]> Cc: [email protected] --- common/board_f.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/board_f.c b/common/board_f.c index 85b888d4bb8..9efcd9499a9 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -921,13 +921,13 @@ static void initcall_run_f(void) * For simplicity it should remain an ordered list of function calls. */ INITCALL(setup_mon_len); + INITCALL(initf_malloc); #if CONFIG_IS_ENABLED(OF_CONTROL) INITCALL(fdtdec_setup); #endif #if CONFIG_IS_ENABLED(TRACE_EARLY) INITCALL(trace_early_init); #endif - INITCALL(initf_malloc); INITCALL(initf_upl); INITCALL(log_init); INITCALL(initf_bootstage); /* uses its own timer, so does not need DM */ -- 2.53.0
