Commit 6e9c9686 authored by Rob Herring's avatar Rob Herring

scripts/dtc: Update to upstream version v1.6.0-31-gcbca977ea121

This adds the following commits from upstream:

cbca977ea121 checks: Allow PCI bridge child nodes without an address
73e0f143b73d libfdt: fdt_strerror(): Fix comparison warning
6c2be7d85315 libfdt: fdt_get_string(): Fix sequential write comparison warnings
82525f41d59e libfdt: libfdt_wip: Fix comparison warning
fb1f65f15832 libfdt: fdt_create_with_flags(): Fix comparison warning
f28aa271000b libfdt: fdt_move(): Fix comparison warnings
3d7c6f44195a libfdt: fdt_add_string_(): Fix comparison warning
10f682788c30 libfdt: fdt_node_offset_by_phandle(): Fix comparison warning
07158f4cf2a2 libfdt: overlay: Fix comparison warning
ce9e1f25a7de libfdt: fdt_resize(): Fix comparison warning
faa76fc10bc5 libfdt: fdt_splice_(): Fix comparison warning
54dca0985316 libfdt: fdt_get_string(): Fix comparison warnings
f8e11e61624e libfdt: fdt_grab_space_(): Fix comparison warning
0c43d4d7bf5a libfdt: fdt_mem_rsv(): Fix comparison warnings
442ea3dd1579 libfdt: fdt_offset_ptr(): Fix comparison warnings
ca19c3db2bf6 Makefile: Specify cflags for libyaml
7bb86f1c0956 libfdt: fix fdt_check_node_offset_ w/ VALID_INPUT
3d522abc7571 dtc: Include stdlib.h in util.h
808cdaaf524f dtc: Avoid UB when shifting
3e3138b4a956 libfdt: fix fdt_check_full buffer overrun
Signed-off-by: default avatarRob Herring <robh@kernel.org>
parent 44ec8b20
...@@ -891,10 +891,8 @@ static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct no ...@@ -891,10 +891,8 @@ static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct no
return; return;
prop = get_property(node, "reg"); prop = get_property(node, "reg");
if (!prop) { if (!prop)
FAIL(c, dti, node, "missing PCI reg property");
return; return;
}
cells = (cell_t *)prop->val.val; cells = (cell_t *)prop->val.val;
if (cells[1] || cells[2]) if (cells[1] || cells[2])
......
...@@ -476,8 +476,8 @@ integer_rela: ...@@ -476,8 +476,8 @@ integer_rela:
; ;
integer_shift: integer_shift:
integer_shift DT_LSHIFT integer_add { $$ = $1 << $3; } integer_shift DT_LSHIFT integer_add { $$ = ($3 < 64) ? ($1 << $3) : 0; }
| integer_shift DT_RSHIFT integer_add { $$ = $1 >> $3; } | integer_shift DT_RSHIFT integer_add { $$ = ($3 < 64) ? ($1 >> $3) : 0; }
| integer_add | integer_add
; ;
......
...@@ -134,16 +134,20 @@ int fdt_check_header(const void *fdt) ...@@ -134,16 +134,20 @@ int fdt_check_header(const void *fdt)
const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
{ {
unsigned absoffset = offset + fdt_off_dt_struct(fdt); unsigned int uoffset = offset;
unsigned int absoffset = offset + fdt_off_dt_struct(fdt);
if (offset < 0)
return NULL;
if (!can_assume(VALID_INPUT)) if (!can_assume(VALID_INPUT))
if ((absoffset < offset) if ((absoffset < uoffset)
|| ((absoffset + len) < absoffset) || ((absoffset + len) < absoffset)
|| (absoffset + len) > fdt_totalsize(fdt)) || (absoffset + len) > fdt_totalsize(fdt))
return NULL; return NULL;
if (can_assume(LATEST) || fdt_version(fdt) >= 0x11) if (can_assume(LATEST) || fdt_version(fdt) >= 0x11)
if (((offset + len) < offset) if (((uoffset + len) < uoffset)
|| ((offset + len) > fdt_size_dt_struct(fdt))) || ((offset + len) > fdt_size_dt_struct(fdt)))
return NULL; return NULL;
...@@ -206,10 +210,11 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) ...@@ -206,10 +210,11 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
int fdt_check_node_offset_(const void *fdt, int offset) int fdt_check_node_offset_(const void *fdt, int offset)
{ {
if (can_assume(VALID_INPUT)) if (!can_assume(VALID_INPUT)
return offset; && ((offset < 0) || (offset % FDT_TAGSIZE)))
if ((offset < 0) || (offset % FDT_TAGSIZE) return -FDT_ERR_BADOFFSET;
|| (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE))
if (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE)
return -FDT_ERR_BADOFFSET; return -FDT_ERR_BADOFFSET;
return offset; return offset;
...@@ -217,8 +222,11 @@ int fdt_check_node_offset_(const void *fdt, int offset) ...@@ -217,8 +222,11 @@ int fdt_check_node_offset_(const void *fdt, int offset)
int fdt_check_prop_offset_(const void *fdt, int offset) int fdt_check_prop_offset_(const void *fdt, int offset)
{ {
if ((offset < 0) || (offset % FDT_TAGSIZE) if (!can_assume(VALID_INPUT)
|| (fdt_next_tag(fdt, offset, &offset) != FDT_PROP)) && ((offset < 0) || (offset % FDT_TAGSIZE)))
return -FDT_ERR_BADOFFSET;
if (fdt_next_tag(fdt, offset, &offset) != FDT_PROP)
return -FDT_ERR_BADOFFSET; return -FDT_ERR_BADOFFSET;
return offset; return offset;
...@@ -306,9 +314,12 @@ const char *fdt_find_string_(const char *strtab, int tabsize, const char *s) ...@@ -306,9 +314,12 @@ const char *fdt_find_string_(const char *strtab, int tabsize, const char *s)
int fdt_move(const void *fdt, void *buf, int bufsize) int fdt_move(const void *fdt, void *buf, int bufsize)
{ {
if (!can_assume(VALID_INPUT) && bufsize < 0)
return -FDT_ERR_NOSPACE;
FDT_RO_PROBE(fdt); FDT_RO_PROBE(fdt);
if (fdt_totalsize(fdt) > bufsize) if (fdt_totalsize(fdt) > (unsigned int)bufsize)
return -FDT_ERR_NOSPACE; return -FDT_ERR_NOSPACE;
memmove(buf, fdt, fdt_totalsize(fdt)); memmove(buf, fdt, fdt_totalsize(fdt));
......
...@@ -241,6 +241,7 @@ static int overlay_update_local_node_references(void *fdto, ...@@ -241,6 +241,7 @@ static int overlay_update_local_node_references(void *fdto,
if (fixup_len % sizeof(uint32_t)) if (fixup_len % sizeof(uint32_t))
return -FDT_ERR_BADOVERLAY; return -FDT_ERR_BADOVERLAY;
fixup_len /= sizeof(uint32_t);
tree_val = fdt_getprop(fdto, tree_node, name, &tree_len); tree_val = fdt_getprop(fdto, tree_node, name, &tree_len);
if (!tree_val) { if (!tree_val) {
...@@ -250,7 +251,7 @@ static int overlay_update_local_node_references(void *fdto, ...@@ -250,7 +251,7 @@ static int overlay_update_local_node_references(void *fdto,
return tree_len; return tree_len;
} }
for (i = 0; i < (fixup_len / sizeof(uint32_t)); i++) { for (i = 0; i < fixup_len; i++) {
fdt32_t adj_val; fdt32_t adj_val;
uint32_t poffset; uint32_t poffset;
......
...@@ -53,7 +53,7 @@ const char *fdt_get_string(const void *fdt, int stroffset, int *lenp) ...@@ -53,7 +53,7 @@ const char *fdt_get_string(const void *fdt, int stroffset, int *lenp)
err = -FDT_ERR_BADOFFSET; err = -FDT_ERR_BADOFFSET;
absoffset = stroffset + fdt_off_dt_strings(fdt); absoffset = stroffset + fdt_off_dt_strings(fdt);
if (absoffset >= totalsize) if (absoffset >= (unsigned)totalsize)
goto fail; goto fail;
len = totalsize - absoffset; len = totalsize - absoffset;
...@@ -61,17 +61,19 @@ const char *fdt_get_string(const void *fdt, int stroffset, int *lenp) ...@@ -61,17 +61,19 @@ const char *fdt_get_string(const void *fdt, int stroffset, int *lenp)
if (stroffset < 0) if (stroffset < 0)
goto fail; goto fail;
if (can_assume(LATEST) || fdt_version(fdt) >= 17) { if (can_assume(LATEST) || fdt_version(fdt) >= 17) {
if (stroffset >= fdt_size_dt_strings(fdt)) if ((unsigned)stroffset >= fdt_size_dt_strings(fdt))
goto fail; goto fail;
if ((fdt_size_dt_strings(fdt) - stroffset) < len) if ((fdt_size_dt_strings(fdt) - stroffset) < len)
len = fdt_size_dt_strings(fdt) - stroffset; len = fdt_size_dt_strings(fdt) - stroffset;
} }
} else if (fdt_magic(fdt) == FDT_SW_MAGIC) { } else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
if ((stroffset >= 0) unsigned int sw_stroffset = -stroffset;
|| (stroffset < -fdt_size_dt_strings(fdt)))
if ((stroffset >= 0) ||
(sw_stroffset > fdt_size_dt_strings(fdt)))
goto fail; goto fail;
if ((-stroffset) < len) if (sw_stroffset < len)
len = -stroffset; len = sw_stroffset;
} else { } else {
err = -FDT_ERR_INTERNAL; err = -FDT_ERR_INTERNAL;
goto fail; goto fail;
...@@ -157,8 +159,8 @@ int fdt_generate_phandle(const void *fdt, uint32_t *phandle) ...@@ -157,8 +159,8 @@ int fdt_generate_phandle(const void *fdt, uint32_t *phandle)
static const struct fdt_reserve_entry *fdt_mem_rsv(const void *fdt, int n) static const struct fdt_reserve_entry *fdt_mem_rsv(const void *fdt, int n)
{ {
int offset = n * sizeof(struct fdt_reserve_entry); unsigned int offset = n * sizeof(struct fdt_reserve_entry);
int absoffset = fdt_off_mem_rsvmap(fdt) + offset; unsigned int absoffset = fdt_off_mem_rsvmap(fdt) + offset;
if (!can_assume(VALID_INPUT)) { if (!can_assume(VALID_INPUT)) {
if (absoffset < fdt_off_mem_rsvmap(fdt)) if (absoffset < fdt_off_mem_rsvmap(fdt))
...@@ -680,7 +682,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle) ...@@ -680,7 +682,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)
{ {
int offset; int offset;
if ((phandle == 0) || (phandle == -1)) if ((phandle == 0) || (phandle == ~0U))
return -FDT_ERR_BADPHANDLE; return -FDT_ERR_BADPHANDLE;
FDT_RO_PROBE(fdt); FDT_RO_PROBE(fdt);
......
...@@ -59,7 +59,7 @@ static int fdt_splice_(void *fdt, void *splicepoint, int oldlen, int newlen) ...@@ -59,7 +59,7 @@ static int fdt_splice_(void *fdt, void *splicepoint, int oldlen, int newlen)
if ((oldlen < 0) || (soff + oldlen < soff) || (soff + oldlen > dsize)) if ((oldlen < 0) || (soff + oldlen < soff) || (soff + oldlen > dsize))
return -FDT_ERR_BADOFFSET; return -FDT_ERR_BADOFFSET;
if ((p < (char *)fdt) || (dsize + newlen < oldlen)) if ((p < (char *)fdt) || (dsize + newlen < (unsigned)oldlen))
return -FDT_ERR_BADOFFSET; return -FDT_ERR_BADOFFSET;
if (dsize - oldlen + newlen > fdt_totalsize(fdt)) if (dsize - oldlen + newlen > fdt_totalsize(fdt))
return -FDT_ERR_NOSPACE; return -FDT_ERR_NOSPACE;
......
...@@ -40,7 +40,7 @@ static struct fdt_errtabent fdt_errtable[] = { ...@@ -40,7 +40,7 @@ static struct fdt_errtabent fdt_errtable[] = {
FDT_ERRTABENT(FDT_ERR_NOPHANDLES), FDT_ERRTABENT(FDT_ERR_NOPHANDLES),
FDT_ERRTABENT(FDT_ERR_BADFLAGS), FDT_ERRTABENT(FDT_ERR_BADFLAGS),
}; };
#define FDT_ERRTABSIZE (sizeof(fdt_errtable) / sizeof(fdt_errtable[0])) #define FDT_ERRTABSIZE ((int)(sizeof(fdt_errtable) / sizeof(fdt_errtable[0])))
const char *fdt_strerror(int errval) const char *fdt_strerror(int errval)
{ {
...@@ -48,7 +48,7 @@ const char *fdt_strerror(int errval) ...@@ -48,7 +48,7 @@ const char *fdt_strerror(int errval)
return "<valid offset/length>"; return "<valid offset/length>";
else if (errval == 0) else if (errval == 0)
return "<no error>"; return "<no error>";
else if (errval > -FDT_ERRTABSIZE) { else if (-errval < FDT_ERRTABSIZE) {
const char *s = fdt_errtable[-errval].str; const char *s = fdt_errtable[-errval].str;
if (s) if (s)
......
...@@ -93,8 +93,8 @@ static inline uint32_t sw_flags(void *fdt) ...@@ -93,8 +93,8 @@ static inline uint32_t sw_flags(void *fdt)
static void *fdt_grab_space_(void *fdt, size_t len) static void *fdt_grab_space_(void *fdt, size_t len)
{ {
int offset = fdt_size_dt_struct(fdt); unsigned int offset = fdt_size_dt_struct(fdt);
int spaceleft; unsigned int spaceleft;
spaceleft = fdt_totalsize(fdt) - fdt_off_dt_struct(fdt) spaceleft = fdt_totalsize(fdt) - fdt_off_dt_struct(fdt)
- fdt_size_dt_strings(fdt); - fdt_size_dt_strings(fdt);
...@@ -108,8 +108,8 @@ static void *fdt_grab_space_(void *fdt, size_t len) ...@@ -108,8 +108,8 @@ static void *fdt_grab_space_(void *fdt, size_t len)
int fdt_create_with_flags(void *buf, int bufsize, uint32_t flags) int fdt_create_with_flags(void *buf, int bufsize, uint32_t flags)
{ {
const size_t hdrsize = FDT_ALIGN(sizeof(struct fdt_header), const int hdrsize = FDT_ALIGN(sizeof(struct fdt_header),
sizeof(struct fdt_reserve_entry)); sizeof(struct fdt_reserve_entry));
void *fdt = buf; void *fdt = buf;
if (bufsize < hdrsize) if (bufsize < hdrsize)
...@@ -152,6 +152,9 @@ int fdt_resize(void *fdt, void *buf, int bufsize) ...@@ -152,6 +152,9 @@ int fdt_resize(void *fdt, void *buf, int bufsize)
FDT_SW_PROBE(fdt); FDT_SW_PROBE(fdt);
if (bufsize < 0)
return -FDT_ERR_NOSPACE;
headsize = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt); headsize = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
tailsize = fdt_size_dt_strings(fdt); tailsize = fdt_size_dt_strings(fdt);
...@@ -159,7 +162,7 @@ int fdt_resize(void *fdt, void *buf, int bufsize) ...@@ -159,7 +162,7 @@ int fdt_resize(void *fdt, void *buf, int bufsize)
headsize + tailsize > fdt_totalsize(fdt)) headsize + tailsize > fdt_totalsize(fdt))
return -FDT_ERR_INTERNAL; return -FDT_ERR_INTERNAL;
if ((headsize + tailsize) > bufsize) if ((headsize + tailsize) > (unsigned)bufsize)
return -FDT_ERR_NOSPACE; return -FDT_ERR_NOSPACE;
oldtail = (char *)fdt + fdt_totalsize(fdt) - tailsize; oldtail = (char *)fdt + fdt_totalsize(fdt) - tailsize;
...@@ -247,18 +250,18 @@ int fdt_end_node(void *fdt) ...@@ -247,18 +250,18 @@ int fdt_end_node(void *fdt)
static int fdt_add_string_(void *fdt, const char *s) static int fdt_add_string_(void *fdt, const char *s)
{ {
char *strtab = (char *)fdt + fdt_totalsize(fdt); char *strtab = (char *)fdt + fdt_totalsize(fdt);
int strtabsize = fdt_size_dt_strings(fdt); unsigned int strtabsize = fdt_size_dt_strings(fdt);
int len = strlen(s) + 1; unsigned int len = strlen(s) + 1;
int struct_top, offset; unsigned int struct_top, offset;
offset = -strtabsize - len; offset = strtabsize + len;
struct_top = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt); struct_top = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
if (fdt_totalsize(fdt) + offset < struct_top) if (fdt_totalsize(fdt) - offset < struct_top)
return 0; /* no more room :( */ return 0; /* no more room :( */
memcpy(strtab + offset, s, len); memcpy(strtab - offset, s, len);
fdt_set_size_dt_strings(fdt, strtabsize + len); fdt_set_size_dt_strings(fdt, strtabsize + len);
return offset; return -offset;
} }
/* Must only be used to roll back in case of error */ /* Must only be used to roll back in case of error */
......
...@@ -23,7 +23,7 @@ int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset, ...@@ -23,7 +23,7 @@ int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
if (!propval) if (!propval)
return proplen; return proplen;
if (proplen < (len + idx)) if ((unsigned)proplen < (len + idx))
return -FDT_ERR_NOSPACE; return -FDT_ERR_NOSPACE;
memcpy((char *)propval + idx, val, len); memcpy((char *)propval + idx, val, len);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#ifndef UTIL_H #ifndef UTIL_H
#define UTIL_H #define UTIL_H
#include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
#include <getopt.h> #include <getopt.h>
......
#define DTC_VERSION "DTC 1.6.0-g9d7888cb" #define DTC_VERSION "DTC 1.6.0-gcbca977e"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment