This file provides read-write access to the device tree and includes mostly checks of the header. Allow these checks to be disabled to reduce code size. Signed-off-by: Simon Glass <sjg@xxxxxxxxxxxx> --- libfdt/fdt_rw.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c index 8795947..4ff3aab 100644 --- a/libfdt/fdt_rw.c +++ b/libfdt/fdt_rw.c @@ -13,6 +13,8 @@ static int fdt_blocks_misordered_(const void *fdt, int mem_rsv_size, int struct_size) { + if (!_check2()) + return false; return (fdt_off_mem_rsvmap(fdt) < FDT_ALIGN(sizeof(struct fdt_header), 8)) || (fdt_off_dt_struct(fdt) < (fdt_off_mem_rsvmap(fdt) + mem_rsv_size)) @@ -24,6 +26,8 @@ static int fdt_blocks_misordered_(const void *fdt, static int fdt_rw_probe_(void *fdt) { + if (!_check2()) + return 0; FDT_RO_PROBE(fdt); if (fdt_version(fdt) < 17) @@ -40,7 +44,7 @@ static int fdt_rw_probe_(void *fdt) #define FDT_RW_PROBE(fdt) \ { \ int err_; \ - if ((err_ = fdt_rw_probe_(fdt)) != 0) \ + if (_check2() && (err_ = fdt_rw_probe_(fdt)) != 0) \ return err_; \ } @@ -120,7 +124,8 @@ static int fdt_find_add_string_(void *fdt, const char *s, int *allocated) int len = strlen(s) + 1; int err; - *allocated = 0; + if (_check1()) + *allocated = 0; p = fdt_find_string_(strtab, fdt_size_dt_strings(fdt), s); if (p) @@ -132,7 +137,8 @@ static int fdt_find_add_string_(void *fdt, const char *s, int *allocated) if (err) return err; - *allocated = 1; + if (_check1()) + *allocated = 1; memcpy(new, s, len); return (new - strtab); @@ -206,7 +212,7 @@ static int fdt_add_property_(void *fdt, int nodeoffset, const char *name, err = fdt_splice_struct_(fdt, *prop, 0, proplen); if (err) { - if (allocated) + if (_check1() && allocated) fdt_del_last_string_(fdt, name); return err; } -- 2.22.0.657.g960e92d24f-goog