Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1244182imm; Wed, 23 May 2018 12:41:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoXPoQFEZU8lTxvDjBdlG3P1rKn4wPkGecPeZq7HrT5MACkde/MeAIoLaUPdjmZ+jPR7ZJR X-Received: by 2002:a62:d6da:: with SMTP id a87-v6mr4155856pfl.200.1527104516991; Wed, 23 May 2018 12:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527104516; cv=none; d=google.com; s=arc-20160816; b=qk2rU4W7BT57cVgV3HPIvc/1LcOxAX5t1IfGSgWPHOmOykBN07mrSfPdXBoIcV3U9L 7aMki8j7q2W6aE34CgoD72kavQI9vxwnTuD3YgXKmtUISztcAuV+8l1WV2JQ/Xf5kxpu 9wYIswpeBerNHyMf7sB4BCJm09fMHjr02eHQhzTkf+lxBy5Ym7DeOv1XKX5pdKWOKjFq 4t2UfeP+/l7dCVXdV/fH1x3CcNeYDQ+E6xV0k7PQ/MDERfzrXmQbGm7ktojXb2G/93Le sJZb1F6F9ZnO5fxfnI4D8Pym1DERXGaXfo1c8BxK4sL3gagQnCIvOKijm/AUTIzfVJn1 ek7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=2272hb3ZWFnxa7Im+E6nZJvtt+yLWHIQLcIvGPmUGGU=; b=TtmVqzV9yeVRZgnUjrydJ9JaJ/D1nVlrKzIUqM3WV7cfPxkyEXgGSSv4tQPfoRXTuL 4WJYBkmMeWUMNT5hClzMQQxGYzMTWEUoflkj2+4ygXEMpQcs5om09qoxqQq94KNskCQE FKCJkr4Dcaoh7pQlZz+jPZX+jBQ0oTHNzWrhAFtxblhUe9IKlrE8Dg79pURVvSIDYxFt V40va8ufZNwUczlf+K5C1GRSugnh1oRrB6LPViLEfuEnDp4QqCkLiD1IV6EHccO7Pe/X dF+yrKdSd+6FgMZWvtVy+dBsM95cB7TxGcpQA9dK3s0IyW8Zs2D/5lI5ox3jfsTQ/jWM A3xg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay10-v6si19212543plb.120.2018.05.23.12.41.42; Wed, 23 May 2018 12:41:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934795AbeEWTju (ORCPT + 99 others); Wed, 23 May 2018 15:39:50 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:13785 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934262AbeEWTjB (ORCPT ); Wed, 23 May 2018 15:39:01 -0400 X-IronPort-AV: E=Sophos;i="5.49,434,1520895600"; d="scan'208";a="328129391" Received: from palace.lip6.fr (HELO localhost.localdomain) ([132.227.105.202]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA256; 23 May 2018 21:38:58 +0200 From: Julia Lawall To: Kishon Vijay Abraham I Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] phy: add missing of_node_put Date: Wed, 23 May 2018 21:07:13 +0200 Message-Id: <1527102436-13447-3-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527102436-13447-1-git-send-email-Julia.Lawall@lip6.fr> References: <1527102436-13447-1-git-send-email-Julia.Lawall@lip6.fr> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The device node iterators perform an of_node_get on each iteration, so a jump out of the loop requires an of_node_put. The semantic patch that fixes this problem in the break case is as follows (http://coccinelle.lip6.fr): // @@ expression root,e; local idexpression child; iterator name for_each_child_of_node; @@ for_each_child_of_node(root, child) { ... when != of_node_put(child) when != e = child + of_node_put(child); ? break; ... } ... when != child // Signed-off-by: Julia Lawall --- drivers/phy/hisilicon/phy-hisi-inno-usb2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/phy/hisilicon/phy-hisi-inno-usb2.c b/drivers/phy/hisilicon/phy-hisi-inno-usb2.c index 5243812..0da14b6 100644 --- a/drivers/phy/hisilicon/phy-hisi-inno-usb2.c +++ b/drivers/phy/hisilicon/phy-hisi-inno-usb2.c @@ -154,14 +154,18 @@ static int hisi_inno_phy_probe(struct platform_device *pdev) struct phy *phy; rst = of_reset_control_get_exclusive(child, NULL); - if (IS_ERR(rst)) + if (IS_ERR(rst)) { + of_node_put(child); return PTR_ERR(rst); + } priv->ports[i].utmi_rst = rst; priv->ports[i].priv = priv; phy = devm_phy_create(dev, child, &hisi_inno_phy_ops); - if (IS_ERR(phy)) + if (IS_ERR(phy)) { + of_node_put(child); return PTR_ERR(phy); + } phy_set_bus_width(phy, 8); phy_set_drvdata(phy, &priv->ports[i]); @@ -169,6 +173,7 @@ static int hisi_inno_phy_probe(struct platform_device *pdev) if (i > INNO_PHY_PORT_NUM) { dev_warn(dev, "Support %d ports in maximum\n", i); + of_node_put(child); break; } }