aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Clément Tosi <ptosi@google.com>2022-07-29 14:00:19 +0100
committerDavid Gibson <david@gibson.dropbear.id.au>2022-07-30 13:52:33 +1000
commit50454658f2b5c8968ccd7856d94020c893a4be46 (patch)
treef965ed3fc12f9d633297534eb8f24878cf7445a2
parente64a204196c924288b8bcd741d969160cd9ac6d9 (diff)
downloaddtc-50454658f2b5c8968ccd7856d94020c893a4be46.tar.gz
libfdt: Don't mask fdt_get_name() returned error
Return the error code from fdt_get_name() (contained in len when the result is NULL) instead of masking it with FDT_ERR_BADSTRUCTURE. Fixes: fda71da26e7f ("libfdt: Handle failed get_name() on BEGIN_NODE") Reported-by: Mike McTernan <mikemcternan@google.com> Signed-off-by: Pierre-Clément Tosi <ptosi@google.com> Message-Id: <20220729130019.804288-1-ptosi@google.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--libfdt/fdt_check.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libfdt/fdt_check.c b/libfdt/fdt_check.c
index 71390ee..a21ebbc 100644
--- a/libfdt/fdt_check.c
+++ b/libfdt/fdt_check.c
@@ -66,7 +66,10 @@ int fdt_check_full(const void *fdt, size_t bufsize)
int len;
name = fdt_get_name(fdt, offset, &len);
- if (!name || *name || len)
+ if (!name)
+ return len;
+
+ if (*name || len)
return -FDT_ERR_BADSTRUCTURE;
}
break;