summaryrefslogtreecommitdiff
path: root/libfdt/fdt_ro.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2018-03-25 22:54:22 +1100
committerDavid Gibson <david@gibson.dropbear.id.au>2018-06-07 11:48:20 +1000
commit719d582e98ec9c696c3e3c74e6efb357fd2168f8 (patch)
treeef8f6c4f9b41e91a30abd3e7f19986acfb703ae5 /libfdt/fdt_ro.c
parent70166d62a27f39b15f931b7bf3ffbaa1478fadcf (diff)
downloaddevice-tree-compiler-719d582e98ec9c696c3e3c74e6efb357fd2168f8.tar.gz
libfdt: Propagate name errors in fdt_getprop_by_offset()
fdt_getprop_by_offset() doesn't check for errors from fdt_string() - after all, until very recently it couldn't fail. Now it can, so we need to propagate errors up to the caller. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'libfdt/fdt_ro.c')
-rw-r--r--libfdt/fdt_ro.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 347aa7b..d4cec0e 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -461,8 +461,18 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
prop = fdt_get_property_by_offset_(fdt, offset, lenp);
if (!prop)
return NULL;
- if (namep)
- *namep = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
+ if (namep) {
+ const char *name;
+ int namelen;
+ name = fdt_get_string(fdt, fdt32_to_cpu(prop->nameoff),
+ &namelen);
+ if (!name) {
+ if (lenp)
+ *lenp = namelen;
+ return NULL;
+ }
+ *namep = name;
+ }
/* Handle realignment */
if (fdt_version(fdt) < 0x10 && (offset + sizeof(*prop)) % 8 &&