From: <Oleg.Karfich@wago.com>
To: barebox@lists.infradead.org
Cc: Oleg.Karfich@wago.com
Subject: [PATCH] commands: of_property: do not free data in general
Date: Mon, 27 Aug 2018 13:57:48 +0000 [thread overview]
Message-ID: <1535378254-2593-1-git-send-email-oleg.karfich@wago.com> (raw)
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@wago.com>
---
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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2018-08-27 13:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-27 13:57 Oleg.Karfich [this message]
2018-08-27 14:57 ` Baeuerle, Florian
2018-08-28 6:53 ` Oleg.Karfich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1535378254-2593-1-git-send-email-oleg.karfich@wago.com \
--to=oleg.karfich@wago.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox