[rtems commit] libfdt: Propagate name errors in fdt_getprop_by_offset()
Sebastian Huber
sebh at rtems.org
Thu Jul 19 05:07:42 UTC 2018
Module: rtems
Branch: master
Commit: 6bc883b7370d0b655e5aba009031cde1dc2eb226
Changeset: http://git.rtems.org/rtems/commit/?id=6bc883b7370d0b655e5aba009031cde1dc2eb226
Author: David Gibson <david at gibson.dropbear.id.au>
Date: Sun Mar 25 22:54:22 2018 +1100
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 at gibson.dropbear.id.au>
Tested-by: Alexey Kardashevskiy <aik at ozlabs.ru>
Reviewed-by: Alexey Kardashevskiy <aik at ozlabs.ru>
Reviewed-by: Simon Glass <sjg at chromium.org>
---
cpukit/dtc/libfdt/fdt_ro.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/cpukit/dtc/libfdt/fdt_ro.c b/cpukit/dtc/libfdt/fdt_ro.c
index 347aa7b..d4cec0e 100644
--- a/cpukit/dtc/libfdt/fdt_ro.c
+++ b/cpukit/dtc/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 &&
More information about the vc
mailing list