From: Simon Glass Date: Sun, 12 Nov 2023 15:27:45 +0000 (-0700) Subject: fdt: Check for a valid fdt in oftree_ensure() X-Git-Url: http://git.dujemihanovic.xyz/repo?a=commitdiff_plain;h=9578dd856a72b0412fa65480d8e3c76a52a6cba1;p=u-boot.git 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 --- diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index f72ea416cf..21a233f90f 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -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;