[PATCH 1/3] of: Fix memory hole in of_find_node_by_reproducible_name()

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

 



of_get_reproducible_name() returns an allocated string, so we must free
it.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 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@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