From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B136C433FF for ; Fri, 2 Aug 2019 09:34:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 05A88217D6 for ; Fri, 2 Aug 2019 09:34:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738473; bh=OnJ0pGzYVdVkpNSAE9LhMP+WSPRMGT9H0u+zkc99lXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=lOACNdy0/1RmgPUO3jjkjrFsiPAjn06sv0WTim5UeReNB31DBVAmCLZzSMaPsJmIq l0FylPIjYxKKlgNgKSD1oeJnig74kv8t16+ufv4ZVD3V1DBcNd6Mluzk6JuHs17poP Q6W7yeb2XR0H2iKckKa/ye3tTY83jokVhY6CH10I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391564AbfHBJeb (ORCPT ); Fri, 2 Aug 2019 05:34:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:34340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391555AbfHBJe1 (ORCPT ); Fri, 2 Aug 2019 05:34:27 -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 18924217D4; Fri, 2 Aug 2019 09:34:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738466; bh=OnJ0pGzYVdVkpNSAE9LhMP+WSPRMGT9H0u+zkc99lXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OIt+atk3SnIi3ikIq/tsw+wBCX8b4uyy33q5Dr+zFZHGbCQaabNZptmLfWkJwCtvg 4s6RAyga/Sej6cQhLtJoOoh4YN/PI9qwTcCufAYSE+xTNuZAUj4y5J+zZeW9ArtGvs pmwJnVO4dFWPRk76cdoi4fGflAuLotCqoaP3UlzI= 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.4 115/158] phy: renesas: rcar-gen2: Fix memory leak at error paths Date: Fri, 2 Aug 2019 11:28:56 +0200 Message-Id: <20190802092227.435228705@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092203.671944552@linuxfoundation.org> References: <20190802092203.671944552@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/phy-rcar-gen2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/phy/phy-rcar-gen2.c b/drivers/phy/phy-rcar-gen2.c index c7a05996d5c1..99d2b73654f4 100644 --- a/drivers/phy/phy-rcar-gen2.c +++ b/drivers/phy/phy-rcar-gen2.c @@ -287,6 +287,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]; @@ -302,6 +303,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