From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 1/3] of: Fix memory hole in of_find_node_by_reproducible_name()
Date: Thu, 12 Sep 2019 10:35:03 +0200 [thread overview]
Message-ID: <20190912083505.4162-1-s.hauer@pengutronix.de> (raw)
of_get_reproducible_name() returns an allocated string, so we must free
it.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/of/base.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 838f530f85..22077fa397 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2306,9 +2306,17 @@ struct device_node *of_find_node_by_reproducible_name(struct device_node *from,
{
struct device_node *np;
- of_tree_for_each_node_from(np, from)
- if (!of_node_cmp(of_get_reproducible_name(np), name))
+ of_tree_for_each_node_from(np, from) {
+ char *rep = of_get_reproducible_name(np);
+ int res;
+
+ res = of_node_cmp(rep, name);
+
+ free(rep);
+
+ if (!res)
return np;
+ }
return NULL;
}
--
2.23.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2019-09-12 8:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-12 8:35 Sascha Hauer [this message]
2019-09-12 8:35 ` [PATCH 2/3] of: add of_diff() Sascha Hauer
2019-09-12 8:35 ` [PATCH 3/3] add of_diff command Sascha Hauer
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=20190912083505.4162-1-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--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