diff mbox series

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

Message ID 20210903131625.2153838-2-thierry.reding@gmail.com
State Accepted
Commit d5598cfa9bcab50812b2b416af91c2a37be67531
Delegated to: Tom Warren
Headers show
Series ARM: tegra: Support EMC frequency tables on Tegra210 | expand

Commit Message

Thierry Reding Sept. 3, 2021, 1:16 p.m. UTC
From: Thierry Reding <treding@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@nvidia.com>
---
 lib/fdtdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Glass Sept. 30, 2021, 4:09 a.m. UTC | #1
On Fri, 3 Sept 2021 at 07:16, Thierry Reding <thierry.reding@gmail.com> wrote:
>
> From: Thierry Reding <treding@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@nvidia.com>
> ---
>  lib/fdtdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

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]);