From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-ea0-x230.google.com ([2a00:1450:4013:c01::230]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UuVp1-0001nI-HX for barebox@lists.infradead.org; Wed, 03 Jul 2013 22:46:48 +0000 Received: by mail-ea0-f176.google.com with SMTP id z15so392268ead.7 for ; Wed, 03 Jul 2013 15:46:25 -0700 (PDT) From: Sebastian Hesselbarth Date: Thu, 4 Jul 2013 00:46:18 +0200 Message-Id: <1372891578-1871-4-git-send-email-sebastian.hesselbarth@gmail.com> In-Reply-To: <1372891578-1871-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1372891578-1871-1-git-send-email-sebastian.hesselbarth@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 3/3] OF: base: fix infinite loop in of_find_node_with_property To: Sebastian Hesselbarth Cc: barebox@lists.infradead.org of_find_node_with_property suffers from infinite looping, because it does not check for root node of the tree iterated over. This adds a check for parent pointer of last tested iterator entry, which is NULL for the root node. Also set from node to current root_node if NULL. Signed-off-by: Sebastian Hesselbarth --- Cc: barebox@lists.infradead.org Cc: Hiroki Nishimoto --- drivers/of/base.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index 25f2e96..0500c86 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -363,10 +363,16 @@ struct device_node *of_find_node_with_property(struct device_node *from, { struct device_node *np; + if (!from) + from = root_node; + of_tree_for_each_node(np, from) { struct property *pp = of_find_property(np, prop_name, NULL); if (pp) return np; + /* check for root node */ + if (!np->parent) + break; } return NULL; -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox