summaryrefslogtreecommitdiffstats
path: root/commands/of_property.c
diff options
context:
space:
mode:
authorOleg.Karfich@wago.com <Oleg.Karfich@wago.com>2018-08-28 16:09:46 +0000
committerSascha Hauer <s.hauer@pengutronix.de>2018-08-29 09:19:53 +0200
commit06e9ae9b109f0748d0cfa4c7fa35dc904a367f56 (patch)
treeb478fdb2cdf324f8daa08a2246a297e48f7c7262 /commands/of_property.c
parent7daba4205afd1cffe690aee1f6857b5fb3566e14 (diff)
downloadbarebox-06e9ae9b109f0748d0cfa4c7fa35dc904a367f56.tar.gz
commands: of_property: copy value instead of resizing
Commit 748d1b8 adds the fixup feature to the above command. With this commit an unwanted free(data) on the freshly set property value is done if someone tries to set the value of an already present property (not the case for a new property). Furthermore in fixup mode the pointer fixup->data is freed when the fixup function is called more than once. This leads to a hanging system after calling of_dump -F many times. Fix this issues by copying the data to a new allocated memory area like a new property is created. Signed-off-by: Oleg Karfich <oleg.karfich@wago.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/of_property.c')
-rw-r--r--commands/of_property.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/commands/of_property.c b/commands/of_property.c
index d0b923f..31e9b71 100644
--- a/commands/of_property.c
+++ b/commands/of_property.c
@@ -270,9 +270,8 @@ static int do_of_property_set_now(struct device_node *root, const char *path,
free(pp->value);
pp->value_const = NULL;
- /* limit property data to the actual size */
if (len)
- pp->value = xrealloc(data, len);
+ pp->value = xmemdup(data, len);
else
pp->value = NULL;