configs: colibri_imx7: enable DM_VIDEO
[oweals/u-boot.git] / lib / libfdt / fdt_region.c
index 054c4b302f44a5facfeb51e6b2065051bdd07e38..7e9fa9272e80bdf6d2deda20c284344a646b1ded 100644 (file)
@@ -1,8 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-2-Clause
 /*
  * libfdt - Flat Device Tree manipulation
  * Copyright (C) 2013 Google, Inc
  * Written by Simon Glass <sjg@chromium.org>
- * SPDX-License-Identifier:    GPL-2.0+ BSD-2-Clause
  */
 
 #include <linux/libfdt_env.h>
@@ -96,6 +96,9 @@ int fdt_find_regions(const void *fdt, char * const inc[], int inc_count,
                        break;
 
                case FDT_END_NODE:
+                       /* Depth must never go below -1 */
+                       if (depth < 0)
+                               return -FDT_ERR_BADSTRUCTURE;
                        include = want;
                        want = stack[depth--];
                        while (end > path && *--end != '/')