mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-25 06:00:43 +00:00
fdt: fix 'prop (...) not found!' error in 'fdt set' command
This commit brings things back to the well known working state of the command. - With commit9620d87259
(cmd/fdt: support single value replacement within an array) there was an error introduced modifying (inserting) a property to a device-tree node. fdt_getprop(...) returnes a len with -1 for a non-existing property, but a memcpy with len -1 isn't a good idea and things went wrong (crash). - Some times later Tom did repair this with commit99bb38e2cc
(fdt: Check for NULL return from fdt_getprop in 'fdt set') This repairs the crash but the behaviour of the command isn't like before, it makes it impossible to insert a property. - Signed-off-by: Hannes Schmelzer <oe5hpm@oevsv.at> Acked-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
302466d07f
commit
cee8c35d1b
1 changed files with 3 additions and 5 deletions
|
@ -284,16 +284,14 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||
len = 0;
|
||||
} else {
|
||||
ptmp = fdt_getprop(working_fdt, nodeoffset, prop, &len);
|
||||
if (!ptmp) {
|
||||
printf("prop (%s) not found!\n", prop);
|
||||
return 1;
|
||||
}
|
||||
if (len > SCRATCHPAD) {
|
||||
printf("prop (%d) doesn't fit in scratchpad!\n",
|
||||
len);
|
||||
return 1;
|
||||
}
|
||||
memcpy(data, ptmp, len);
|
||||
if (ptmp != NULL)
|
||||
memcpy(data, ptmp, len);
|
||||
|
||||
ret = fdt_parse_prop(&argv[4], argc - 4, data, &len);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue