* [U-Boot] [PATCH] fdt: fix 'prop (...) not found!' error in 'fdt set' command
@ 2017-08-18 12:41 Hannes Schmelzer
2017-08-27 20:09 ` Simon Glass
0 siblings, 1 reply; 3+ messages in thread
From: Hannes Schmelzer @ 2017-08-18 12:41 UTC (permalink / raw)
To: u-boot
This commit brings things back to the well known working state of the
command.
-
With commit 9620d87259572ef21f0df60988d9a932ca673779
(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 commit 99bb38e2cce9d99238458e0f6d1880c6d2e80a4d
(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>
---
cmd/fdt.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/cmd/fdt.c b/cmd/fdt.c
index 118613f..d7654b2 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -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;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] fdt: fix 'prop (...) not found!' error in 'fdt set' command
2017-08-18 12:41 [U-Boot] [PATCH] fdt: fix 'prop (...) not found!' error in 'fdt set' command Hannes Schmelzer
@ 2017-08-27 20:09 ` Simon Glass
2017-09-04 16:27 ` sjg at google.com
0 siblings, 1 reply; 3+ messages in thread
From: Simon Glass @ 2017-08-27 20:09 UTC (permalink / raw)
To: u-boot
On 18 August 2017 at 06:41, Hannes Schmelzer <oe5hpm@oevsv.at> wrote:
> This commit brings things back to the well known working state of the
> command.
> -
> With commit 9620d87259572ef21f0df60988d9a932ca673779
> (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 commit 99bb38e2cce9d99238458e0f6d1880c6d2e80a4d
> (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>
>
> ---
>
> cmd/fdt.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
Acked-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] fdt: fix 'prop (...) not found!' error in 'fdt set' command
2017-08-27 20:09 ` Simon Glass
@ 2017-09-04 16:27 ` sjg at google.com
0 siblings, 0 replies; 3+ messages in thread
From: sjg at google.com @ 2017-09-04 16:27 UTC (permalink / raw)
To: u-boot
On 18 August 2017 at 06:41, Hannes Schmelzer <oe5hpm@oevsv.at> wrote:
> This commit brings things back to the well known working state of the
> command.
> -
> With commit 9620d87259572ef21f0df60988d9a932ca673779
> (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 commit 99bb38e2cce9d99238458e0f6d1880c6d2e80a4d
> (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>
>
> ---
>
> cmd/fdt.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
Acked-by: Simon Glass <sjg@chromium.org>
Applied to u-boot-dm, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-09-04 16:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-18 12:41 [U-Boot] [PATCH] fdt: fix 'prop (...) not found!' error in 'fdt set' command Hannes Schmelzer
2017-08-27 20:09 ` Simon Glass
2017-09-04 16:27 ` sjg at google.com
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.