]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
lib: libfdt: fdt_region: avoid NULL pointer access
authorPhilippe Reynes <philippe.reynes@softathome.com>
Thu, 2 Jul 2020 17:31:29 +0000 (19:31 +0200)
committerSimon Glass <sjg@chromium.org>
Sat, 25 Jul 2020 20:46:57 +0000 (14:46 -0600)
The function fdt_find_regions look in the exclude list for each
property, even if the name is NULL. It could happen if the fit
image is corrupted. On sandbox, it generates a segfault.

To avoid this issue, if the name of a property is NULL, we report
an error and avoid looking in the exclude list.

Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
common/fdt_region.c

index 667659054a7e6c9cd86aeb57028e38a9149e3e58..ff12c518e97a605e6178a935de33f42e90740b91 100644 (file)
@@ -65,6 +65,8 @@ int fdt_find_regions(const void *fdt, char * const inc[], int inc_count,
                        stop_at = offset;
                        prop = fdt_get_property_by_offset(fdt, offset, NULL);
                        str = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
+                       if (!str)
+                               return -FDT_ERR_BADSTRUCTURE;
                        if (str_in_list(str, exc_prop, exc_prop_count))
                                include = 0;
                        break;