[PATCH 1/9] fdtdec: Allow using fdtdec_get_carveout() in loops

Thierry Reding thierry.reding at gmail.com
Fri Sep 3 15:16:17 CEST 2021


From: Thierry Reding <treding at nvidia.com>

In order make it possible to use fdtdec_get_carveout() in loops, return
FDT_ERR_NOTFOUND when the passed-in index exceeds the number of phandles
present in the given property.

Signed-off-by: Thierry Reding <treding at nvidia.com>
---
 lib/fdtdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 337c4443b032..7f6b6d523232 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1469,7 +1469,7 @@ int fdtdec_get_carveout(const void *blob, const char *node, const char *name,
 
 	if (len < (sizeof(phandle) * (index + 1))) {
 		debug("invalid phandle index\n");
-		return -FDT_ERR_BADPHANDLE;
+		return -FDT_ERR_NOTFOUND;
 	}
 
 	phandle = fdt32_to_cpu(prop[index]);
-- 
2.33.0



More information about the U-Boot mailing list