[PATCH] commands: of_property: do not free data in general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



With commit 748d1b8 the function do_of_property_set_now is introduced. With this
commit an unwanted free(data) is added wich leads to that an free on the value
is done that is previously set to the property. As a consequence the command
of_dump reads freed data an printis the value as hex. Fix this by moving
free(data) to the right place like before the above commit.

Signed-off-by: Oleg Karfich <oleg.karfich@xxxxxxxx>
---
 commands/of_property.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/commands/of_property.c b/commands/of_property.c
index 8ce12e5..ea32e51 100644
--- a/commands/of_property.c
+++ b/commands/of_property.c
@@ -275,10 +275,12 @@ static int do_of_property_set_now(struct device_node *root, const char *path,
 		pp->value_const = NULL;
 
 		/* limit property data to the actual size */
-		if (len)
+		if (len) {
 			pp->value = xrealloc(data, len);
-		else
+		} else {
 			pp->value = NULL;
+			free(data);
+		}
 
 		pp->length = len;
 	} else {
@@ -374,7 +376,6 @@ static int do_of_property(int argc, char *argv[])
 				free(data);
 		} else {
 			ret = do_of_property_set_now(NULL, path, propname, data, len);
-			free(data);
 		}
 
 		return ret;
-- 
2.7.4

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux