aboutsummaryrefslogtreecommitdiffstats
path: root/libfdt/fdt_rw.c
diff options
context:
space:
mode:
authorOleksandr Tymoshenko <gonzo@FreeBSD.org>2017-03-10 03:28:43 +0000
committerOleksandr Tymoshenko <gonzo@FreeBSD.org>2017-03-10 03:28:43 +0000
commitf059bd1ebfc4cf2e96c4639ad7fa6cf3a3198a2f (patch)
tree74d52c3db99ba80520d6142e9bc77e2802093021 /libfdt/fdt_rw.c
parentb903311b940763cafe4fb3d8ab3da9c135c17b0c (diff)
downloadsrc-f059bd1ebfc4cf2e96c4639ad7fa6cf3a3198a2f.tar.gz
src-f059bd1ebfc4cf2e96c4639ad7fa6cf3a3198a2f.zip
Import dtc 1.4.3vendor/dtc/1.4.3
Notes
Notes: svn path=/vendor/dtc/dist/; revision=314985 svn path=/vendor/dtc/1.4.3/; revision=314986; tag=vendor/dtc/1.4.3
Diffstat (limited to 'libfdt/fdt_rw.c')
-rw-r--r--libfdt/fdt_rw.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index fdba618f12ae..3fd5847377c9 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -84,9 +84,9 @@ static int _fdt_rw_check_header(void *fdt)
#define FDT_RW_CHECK_HEADER(fdt) \
{ \
- int err; \
- if ((err = _fdt_rw_check_header(fdt)) != 0) \
- return err; \
+ int __err; \
+ if ((__err = _fdt_rw_check_header(fdt)) != 0) \
+ return __err; \
}
static inline int _fdt_data_size(void *fdt)
@@ -101,6 +101,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);
@@ -189,17 +191,13 @@ int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size)
int fdt_del_mem_rsv(void *fdt, int n)
{
struct fdt_reserve_entry *re = _fdt_mem_rsv_w(fdt, n);
- int err;
FDT_RW_CHECK_HEADER(fdt);
if (n >= fdt_num_mem_rsv(fdt))
return -FDT_ERR_NOTFOUND;
- err = _fdt_splice_mem_rsv(fdt, re, 1, 0);
- if (err)
- return err;
- return 0;
+ return _fdt_splice_mem_rsv(fdt, re, 1, 0);
}
static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name,
@@ -285,7 +283,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
if (err)
return err;
- memcpy(prop->data, val, len);
+ if (len)
+ memcpy(prop->data, val, len);
return 0;
}