fdt: Check for a valid fdt in oftree_ensure()

Check the header before starting to use it, since this could provide
very confusing later, when ofnode calls start to fail.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2023-11-12 08:27:45 -07:00 committed by Tom Rini
parent 1de1a03487
commit 9578dd856a

View file

@ -83,6 +83,11 @@ static oftree oftree_ensure(void *fdt)
if (check_tree_count())
return oftree_null();
if (fdt_check_header(fdt)) {
log_err("Invalid device tree blob header\n");
return oftree_null();
}
/* register the new tree */
i = oftree_count++;
oftree_list[i] = fdt;