From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933567AbcA0PUZ (ORCPT ); Wed, 27 Jan 2016 10:20:25 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:36685 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932927AbcA0PUW (ORCPT ); Wed, 27 Jan 2016 10:20:22 -0500 Date: Wed, 27 Jan 2016 20:50:17 +0530 From: Amitoj Kaur Chawla To: pantelis.antoniou@konsulko.com, robh+dt@kernel.org, frowand.list@gmail.com, grant.likely@linaro.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: julia.lawall@lip6.fr Subject: [PATCH] of: resolver: Add missing of_node_put Message-ID: <20160127152017.GA16048@amitoj-Inspiron-3542> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org for_each_child_of_node performs an of_node_get on each iteration, so to break out of the loop an of_node_put is required. Found using Coccinelle. The semantic patch used for this is as follows: // @@ expression e; local idexpression n; @@ for_each_child_of_node(..., n) { ... when != of_node_put(n) when != e = n ( return n; | + of_node_put(n); ? return ...; ) ... } // --- drivers/of/resolver.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c index 640eb4c..e2a0143 100644 --- a/drivers/of/resolver.c +++ b/drivers/of/resolver.c @@ -40,8 +40,10 @@ static struct device_node *__of_find_node_by_full_name(struct device_node *node, for_each_child_of_node(node, child) { found = __of_find_node_by_full_name(child, full_name); - if (found != NULL) + if (found != NULL) { + of_node_put(child); return found; + } } return NULL; -- 1.9.1