]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fdtdec: Allow using fdtdec_get_carveout() in loops
authorThierry Reding <treding@nvidia.com>
Fri, 3 Sep 2021 13:16:17 +0000 (15:16 +0200)
committerTom Warren <twarren@nvidia.com>
Wed, 13 Oct 2021 21:18:30 +0000 (14:18 -0700)
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@nvidia.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Warren <twarren@nvidia.com>
lib/fdtdec.c

index af92e65bde6dac3a3cf5ab9221ab6a6d316337b6..f2861eb395d3b25014a1a4a9f89d8ac0244a1d25 100644 (file)
@@ -1431,7 +1431,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]);