From patchwork Wed Jun 12 10:27:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 166536 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3500936ilk; Wed, 12 Jun 2019 03:29:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzs8+nsREzcZa42qgcmMeOFeugzwDZyFkmTtc9Hz+lnSRz9yzMA/pg7S8oqzhQ50wJeIEbD X-Received: by 2002:a62:4e0c:: with SMTP id c12mr83939438pfb.17.1560335386172; Wed, 12 Jun 2019 03:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560335386; cv=none; d=google.com; s=arc-20160816; b=QF29yAJTzcHycXoySCRXgMR/a289kkY9c1Om4yLB5ekpVRlD20CbMTcWtd2C99Q7Qy 9Rf9RYNA7di73vl87UxBIyW7aFjcfPGuN1ruVYma2DkCc7TPLDU/zQY0nOvoq49zPzlj MBqHuWFcCrl2SRljUh/kxBqICood+q+hN2F6bW2zsnleyGl1Lc/iWaRYxA2oVaGKo8pz psQ/DTRgm7BKIwcwb2G9mW847mWTmJMAHrmFxOOHpa3VN7oAHrCfrF5xww49/t31FOXZ THCMWC96Olun0XTScvxF5aOCYh77MO2lt7yhi8DFLXKW5nYbS2J2f5+Hq23HZOdQtm+k bojw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=XXQQt6ZHl5//GgviHhkN4bTJC0kM8bhZ0blS56iER00=; b=Dr56/h8yfioGcTWOGbj2ie0e9QUdwpzQBfwGMmbixPEJgzNXShoS7SzWCfxgr1XnVi 3DjKKAId8v44mJZxb/inkvoU2Xi7ewXlWELAUy+MnmGznFcjjjsMOCW2Z60offKfptaQ fOiRGUOMRRoA2Pl6df/BZLsI8LvCyzmykKBfU+MmoH4WSdKq6CInxsnwFUmv1uT7f2yE iwyt3zvz99QJPHHHE/NNV6LqMPqcGeoXn5uxGa1f1aviBeMbs2D9ACceqRbfc3/i556V S2/AFTRAzzOnOcW1HaZ8W0PtmF3y6AKy6o5mstagiwoAiHRHCTjOoRXW6luTf+M+cT4h 0Byw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=UeKd8cFz; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m7si4960819pjs.63.2019.06.12.03.29.45; Wed, 12 Jun 2019 03:29:46 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=UeKd8cFz; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732170AbfFLK3o (ORCPT + 30 others); Wed, 12 Jun 2019 06:29:44 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:48708 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732151AbfFLK3o (ORCPT ); Wed, 12 Jun 2019 06:29:44 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x5CAThgQ130060; Wed, 12 Jun 2019 05:29:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1560335383; bh=XXQQt6ZHl5//GgviHhkN4bTJC0kM8bhZ0blS56iER00=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=UeKd8cFzwa9AZ9GwxbAV6VYbVIUV/+VBy0y2594XmqkX5c/BceAYwpaH2vQqNhrd3 C4Gwvi3FrAU1AxjdaoVb4WAyvz5rq7wx2lDNv3lmj5Ncbqz+N9eetdKBpInSOr8d9R V+HW+WcujfBV4pHDF0xl21ZqtQreDb3wcgvQ44Uk= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x5CAThE3038492 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Jun 2019 05:29:43 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 12 Jun 2019 05:29:43 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Wed, 12 Jun 2019 05:29:43 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x5CATTJY128310; Wed, 12 Jun 2019 05:29:39 -0500 From: Kishon Vijay Abraham I To: Greg Kroah-Hartman , CC: Subject: [PATCH 2/6] phy: renesas: rcar-gen2: Fix memory leak at error paths Date: Wed, 12 Jun 2019 15:57:59 +0530 Message-ID: <20190612102803.25398-3-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190612102803.25398-1-kishon@ti.com> References: <20190612102803.25398-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yoshihiro Shimoda This patch fixes memory leak at error paths of the probe function. In for_each_child_of_node, if the loop returns, the driver should call of_put_node() before returns. Reported-by: Julia Lawall Fixes: 1233f59f745b237 ("phy: Renesas R-Car Gen2 PHY driver") Signed-off-by: Yoshihiro Shimoda Reviewed-by: Geert Uytterhoeven Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/renesas/phy-rcar-gen2.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.17.1 diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c index 8dc5710d9c98..2926e4937301 100644 --- a/drivers/phy/renesas/phy-rcar-gen2.c +++ b/drivers/phy/renesas/phy-rcar-gen2.c @@ -391,6 +391,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev) error = of_property_read_u32(np, "reg", &channel_num); if (error || channel_num > 2) { dev_err(dev, "Invalid \"reg\" property\n"); + of_node_put(np); return error; } channel->select_mask = select_mask[channel_num]; @@ -406,6 +407,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev) data->gen2_phy_ops); if (IS_ERR(phy->phy)) { dev_err(dev, "Failed to create PHY\n"); + of_node_put(np); return PTR_ERR(phy->phy); } phy_set_drvdata(phy->phy, phy);