]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fdt: Check for a valid fdt in oftree_ensure()
authorSimon Glass <sjg@chromium.org>
Sun, 12 Nov 2023 15:27:45 +0000 (08:27 -0700)
committerTom Rini <trini@konsulko.com>
Wed, 13 Dec 2023 23:39:05 +0000 (18:39 -0500)
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>
drivers/core/ofnode.c

index f72ea416cf143661aea328e84e6b383892cb3955..21a233f90f0b45c00e7cc996e52534d68a4aae03 100644 (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;