aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/dtc/libfdt/fdt_sw.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/dtc/libfdt/fdt_sw.c')
-rw-r--r--scripts/dtc/libfdt/fdt_sw.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/scripts/dtc/libfdt/fdt_sw.c b/scripts/dtc/libfdt/fdt_sw.c
index 698329e0ccaf..55ebebf1eb20 100644
--- a/scripts/dtc/libfdt/fdt_sw.c
+++ b/scripts/dtc/libfdt/fdt_sw.c
@@ -70,7 +70,7 @@ static int _fdt_sw_check_header(void *fdt)
70 return err; \ 70 return err; \
71 } 71 }
72 72
73static void *_fdt_grab_space(void *fdt, int len) 73static void *_fdt_grab_space(void *fdt, size_t len)
74{ 74{
75 int offset = fdt_size_dt_struct(fdt); 75 int offset = fdt_size_dt_struct(fdt);
76 int spaceleft; 76 int spaceleft;
@@ -82,7 +82,7 @@ static void *_fdt_grab_space(void *fdt, int len)
82 return NULL; 82 return NULL;
83 83
84 fdt_set_size_dt_struct(fdt, offset + len); 84 fdt_set_size_dt_struct(fdt, offset + len);
85 return fdt_offset_ptr_w(fdt, offset, len); 85 return _fdt_offset_ptr_w(fdt, offset);
86} 86}
87 87
88int fdt_create(void *buf, int bufsize) 88int fdt_create(void *buf, int bufsize)
@@ -237,18 +237,17 @@ int fdt_finish(void *fdt)
237 while ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) { 237 while ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) {
238 if (tag == FDT_PROP) { 238 if (tag == FDT_PROP) {
239 struct fdt_property *prop = 239 struct fdt_property *prop =
240 fdt_offset_ptr_w(fdt, offset, sizeof(*prop)); 240 _fdt_offset_ptr_w(fdt, offset);
241 int nameoff; 241 int nameoff;
242 242
243 if (! prop)
244 return -FDT_ERR_BADSTRUCTURE;
245
246 nameoff = fdt32_to_cpu(prop->nameoff); 243 nameoff = fdt32_to_cpu(prop->nameoff);
247 nameoff += fdt_size_dt_strings(fdt); 244 nameoff += fdt_size_dt_strings(fdt);
248 prop->nameoff = cpu_to_fdt32(nameoff); 245 prop->nameoff = cpu_to_fdt32(nameoff);
249 } 246 }
250 offset = nextoffset; 247 offset = nextoffset;
251 } 248 }
249 if (nextoffset < 0)
250 return nextoffset;
252 251
253 /* Finally, adjust the header */ 252 /* Finally, adjust the header */
254 fdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt)); 253 fdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt));