public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kishon Vijay Abraham I <kishon@ti.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, <kishon@ti.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/6] phy: renesas: rcar-gen2: Fix memory leak at error paths
Date: Wed, 12 Jun 2019 15:57:59 +0530	[thread overview]
Message-ID: <20190612102803.25398-3-kishon@ti.com> (raw)
In-Reply-To: <20190612102803.25398-1-kishon@ti.com>

From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

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 <julia.lawall@lip6.fr>
Fixes: 1233f59f745b237 ("phy: Renesas R-Car Gen2 PHY driver")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 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 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);
-- 
2.17.1


  parent reply	other threads:[~2019-06-12 10:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-12 10:27 [GIT PULL v2] PHY: for 5.2-rc Kishon Vijay Abraham I
2019-06-12 10:27 ` [PATCH 1/6] phy: qcom-qusb2: fix missing assignment of ret when calling clk_prepare_enable Kishon Vijay Abraham I
2019-06-12 10:27 ` Kishon Vijay Abraham I [this message]
2019-06-12 10:28 ` [PATCH 3/6] phy: usb: phy-brcm-usb: Remove sysfs attributes upon driver removal Kishon Vijay Abraham I
2019-06-12 10:28 ` [PATCH 4/6] dt-bindings: phy: tegra-xusb: List PLL power supplies Kishon Vijay Abraham I
2019-06-12 10:28 ` [PATCH 5/6] phy: tegra: xusb: Add Tegra124 " Kishon Vijay Abraham I
2019-06-12 10:28 ` [PATCH 6/6] phy: tegra: xusb: Add Tegra210 " Kishon Vijay Abraham I
2019-06-21  6:11 ` [GIT PULL v2] PHY: for 5.2-rc Kishon Vijay Abraham I
2019-06-21  6:40   ` Greg Kroah-Hartman
2019-06-21  7:20     ` Kishon Vijay Abraham I
2019-06-27 13:16       ` Kishon Vijay Abraham I
2019-07-01 10:14         ` Greg Kroah-Hartman
2019-07-01 10:31           ` Kishon Vijay Abraham I
2019-07-01 13:06             ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190612102803.25398-3-kishon@ti.com \
    --to=kishon@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox