diff options
Diffstat (limited to 'lib/libfdt')
-rw-r--r-- | lib/libfdt/fdt_ro.c | 10 | ||||
-rw-r--r-- | lib/libfdt/fdt_rw.c | 4 | ||||
-rw-r--r-- | lib/libfdt/fdt_wip.c | 6 |
3 files changed, 10 insertions, 10 deletions
diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c index 9cc98db6e2b..005f26736f8 100644 --- a/lib/libfdt/fdt_ro.c +++ b/lib/libfdt/fdt_ro.c @@ -60,11 +60,11 @@ uint32_t fdt_get_max_phandle(const void *fdt) return max_phandle; if (offset < 0) - return 0; + return (uint32_t)-1; phandle = fdt_get_phandle(fdt, offset); if (phandle == (uint32_t)-1) - return 0; + continue; if (phandle > max_phandle) max_phandle = phandle; @@ -623,10 +623,8 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset, prop = fdt_getprop(fdt, nodeoffset, "compatible", &len); if (!prop) return len; - if (fdt_stringlist_contains(prop, len, compatible)) - return 0; - else - return 1; + + return !fdt_stringlist_contains(prop, len, compatible); } int fdt_node_offset_by_compatible(const void *fdt, int startoffset, diff --git a/lib/libfdt/fdt_rw.c b/lib/libfdt/fdt_rw.c index 47447b2bce8..87d4030fb14 100644 --- a/lib/libfdt/fdt_rw.c +++ b/lib/libfdt/fdt_rw.c @@ -60,6 +60,8 @@ static int _fdt_splice(void *fdt, void *splicepoint, int oldlen, int newlen) if (((p + oldlen) < p) || ((p + oldlen) > end)) return -FDT_ERR_BADOFFSET; + if ((p < (char *)fdt) || ((end - oldlen + newlen) < (char *)fdt)) + return -FDT_ERR_BADOFFSET; if ((end - oldlen + newlen) > ((char *)fdt + fdt_totalsize(fdt))) return -FDT_ERR_NOSPACE; memmove(p + newlen, p + oldlen, end - p - oldlen); @@ -164,7 +166,7 @@ static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name, int err; *prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen); - if (!(*prop)) + if (!*prop) return oldlen; if ((err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen), diff --git a/lib/libfdt/fdt_wip.c b/lib/libfdt/fdt_wip.c index 216c51287d0..45fb9641206 100644 --- a/lib/libfdt/fdt_wip.c +++ b/lib/libfdt/fdt_wip.c @@ -16,7 +16,7 @@ int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset, const char *name, int namelen, - uint32_t index, const void *val, + uint32_t idx, const void *val, int len) { void *propval; @@ -27,10 +27,10 @@ int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset, if (!propval) return proplen; - if (proplen < (len + index)) + if (proplen < (len + idx)) return -FDT_ERR_NOSPACE; - memcpy(propval + index, val, len); + memcpy((char *)propval + idx, val, len); return 0; } |