Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933626AbbKRWQI (ORCPT ); Wed, 18 Nov 2015 17:16:08 -0500 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:64015 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933209AbbKRWQC (ORCPT ); Wed, 18 Nov 2015 17:16:02 -0500 X-IronPort-AV: E=Sophos;i="5.20,315,1444687200"; d="scan'208";a="188131467" From: Julia Lawall To: David Woodhouse Cc: kernel-janitors@vger.kernel.org, Brian Norris , Maxime Ripard , Chen-Yu Tsai , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Russell King - ARM Linux , Thomas Petazzoni , Andrew Lunn , Bjorn Helgaas , Jason Cooper Subject: [PATCH 2/4] mtd: nand: sunxi: add missing of_node_put Date: Wed, 18 Nov 2015 23:04:12 +0100 Message-Id: <1447884254-26336-3-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447884254-26336-1-git-send-email-Julia.Lawall@lip6.fr> References: <1447884254-26336-1-git-send-email-Julia.Lawall@lip6.fr> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1326 Lines: 53 for_each_child_of_node performs an of_node_get on each iteration, so a break out of the loop requires an of_node_put. A simplified version of the semantic patch that fixes this problem is as follows (http://coccinelle.lip6.fr): // @@ expression root,e; local idexpression child; @@ for_each_child_of_node(root, child) { ... when != of_node_put(child) when != e = child ( return child; | + of_node_put(child); ? return ...; ) ... } // Signed-off-by: Julia Lawall --- drivers/mtd/nand/sunxi_nand.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c index 2ed52e4..1bbcc0c 100644 --- a/drivers/mtd/nand/sunxi_nand.c +++ b/drivers/mtd/nand/sunxi_nand.c @@ -1391,8 +1391,10 @@ static int sunxi_nand_chips_init(struct device *dev, struct sunxi_nfc *nfc) for_each_child_of_node(np, nand_np) { ret = sunxi_nand_chip_init(dev, nfc, nand_np); - if (ret) + if (ret) { + of_node_put(nand_np); return ret; + } } return 0; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/