Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3787687ybi; Mon, 29 Jul 2019 12:37:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRfEu+dyvIUjISh36Ls4KpUQ7dgrBuHpSElQmFTqzduavQZxWOjaNHSUgZHvVA3L4UyLtB X-Received: by 2002:a17:902:381:: with SMTP id d1mr109168363pld.331.1564429045844; Mon, 29 Jul 2019 12:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429045; cv=none; d=google.com; s=arc-20160816; b=h3fX+x9idx1w9rwL9OH+VNhZ7b1YVuGU+aiX/cEf2DfsOPDMU/h8XZ5PfOwtPKl7WG 1ASQbtkCyE0KLEfBh3hILouCY3TnCB6jCWWjoGcQCXq4AsMQpYFstJSRv6sQAxxb619A Vwl0GC2OK0LTlnMBAiXZbPre9c218PhrCNUECv2Qhf2df5L0zM5EOYCD9V2fcuvq+ZkS MTONAY57zJyNozm6+Mg5XC0iCILjJM62jzgZAjk9OoJRPBzh2SDry8BVL4dM6PDnVhL8 UcK5aRFnlkahZcQd9IwijZVPBlzMEF011VX5uBCrQWanszyvZYcoVH5BFWFooUmV1bFb UDxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0uA0WvEcsag+rfBQ8hmTCJ64tJB795UojAa/MOmTv20=; b=M34PiNCO448e7JopybmSq1Y06vWaEiV7SnXyd6TBWFOpJ0S8XJwsnfoJkhJBncanDp AlKDQRTnrGmCVSATxFmGSE4m3h4g5s/bRi8KP+nGv9WP/K+l7reFcWiXe3lVhxT1FcTY a2/fIO6KJlhbTVzQOb9AaZ6dnvq+TAc6MVGl4p0no2BUOh64EyxbICldRcGacCA8UD9w neQSTKv7XU8+wskKqlp8xGdjgaEW7XKAo+WlaUPy1O+eNtTP6FkpCeak+g8lD6H6inVV duMAIaDETzpQNJohxmBHuaXHdnJWSv8pGtjwN+Xx9My6ssVKnlz6iIwzRZwALFWVKsHT dLZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ge0sY79R; 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 15si6376232pgu.98.2019.07.29.12.37.11; Mon, 29 Jul 2019 12:37:25 -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=@kernel.org header.s=default header.b=ge0sY79R; 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 S2388537AbfG2Tfs (ORCPT + 99 others); Mon, 29 Jul 2019 15:35:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:50120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388528AbfG2Tfq (ORCPT ); Mon, 29 Jul 2019 15:35:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 82145217D9; Mon, 29 Jul 2019 19:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428946; bh=H5VIOUyEePA3e7YILjunOmQC973IRxnSoT1mO4GezMc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ge0sY79RohgICVETjNcTBc7DIreW3WXAzt/+VKS0u3uxvn3yaccdxwpmqslKuCoep kjUykcHIUuLt3u0DgmC+C/BtF2TswQb0Bfipfn88lvIntYxfiUubpgHDpMG1JzWTRN gqUv8z11iZVIM8szbwJanH/ULlKSktPrjrQ5xPRI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julia Lawall , Yoshihiro Shimoda , Geert Uytterhoeven , Kishon Vijay Abraham I , Sasha Levin Subject: [PATCH 4.14 237/293] phy: renesas: rcar-gen2: Fix memory leak at error paths Date: Mon, 29 Jul 2019 21:22:08 +0200 Message-Id: <20190729190842.604743846@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit d4a36e82924d3305a17ac987a510f3902df5a4b2 ] 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 Signed-off-by: Sasha Levin --- drivers/phy/renesas/phy-rcar-gen2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c index 97d4dd6ea924..aa02b19b7e0e 100644 --- a/drivers/phy/renesas/phy-rcar-gen2.c +++ b/drivers/phy/renesas/phy-rcar-gen2.c @@ -288,6 +288,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]; @@ -303,6 +304,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev) &rcar_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); -- 2.20.1