linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai3@huawei.com>
To: <krzk@kernel.org>, <thierry.reding@gmail.com>,
	<jonathanh@nvidia.com>, <madalin.bucur@nxp.com>,
	<davem@davemloft.net>, <kuba@kernel.org>, <mperttunen@nvidia.com>,
	<tomeu.vizoso@collabora.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-tegra@vger.kernel.org>,
	<netdev@vger.kernel.org>, <yukuai3@huawei.com>,
	<yi.zhang@huawei.com>
Subject: [PATCH V2] memory: tegra: add missing put_devcie() call in error path of tegra_emc_probe()
Date: Mon, 9 Nov 2020 21:28:47 +0800	[thread overview]
Message-ID: <20201109132847.1738010-1-yukuai3@huawei.com> (raw)
In-Reply-To: <20201102185216.GB13405@kozik-lap>

The reference to device obtained with of_find_device_by_node() should
be dropped. Thus add jump target to fix the exception handling for this
function implementation.

Fixes: 73a7f0a90641("memory: tegra: Add EMC (external memory controller) driver")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 drivers/memory/tegra/tegra124-emc.c           | 21 +++++++++++++------
 .../net/ethernet/freescale/fman/fman_port.c   |  3 +--
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/memory/tegra/tegra124-emc.c b/drivers/memory/tegra/tegra124-emc.c
index 76ace42a688a..7d58a0e0a177 100644
--- a/drivers/memory/tegra/tegra124-emc.c
+++ b/drivers/memory/tegra/tegra124-emc.c
@@ -1207,8 +1207,10 @@ static int tegra_emc_probe(struct platform_device *pdev)
 		return -ENOENT;
 
 	emc->mc = platform_get_drvdata(mc);
-	if (!emc->mc)
-		return -EPROBE_DEFER;
+	if (!emc->mc) {
+		err = -EPROBE_DEFER;
+		goto put_device;
+	}
 
 	ram_code = tegra_read_ram_code();
 
@@ -1217,25 +1219,27 @@ static int tegra_emc_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev,
 			"no memory timings for RAM code %u found in DT\n",
 			ram_code);
-		return -ENOENT;
+		err = -ENOENT;
+		goto put_device;
 	}
 
 	err = tegra_emc_load_timings_from_dt(emc, np);
 	of_node_put(np);
 	if (err)
-		return err;
+		goto put_device;
 
 	if (emc->num_timings == 0) {
 		dev_err(&pdev->dev,
 			"no memory timings for RAM code %u registered\n",
 			ram_code);
-		return -ENOENT;
+		err = -ENOENT;
+		goto put_device;
 	}
 
 	err = emc_init(emc);
 	if (err) {
 		dev_err(&pdev->dev, "EMC initialization failed: %d\n", err);
-		return err;
+		goto put_device;
 	}
 
 	platform_set_drvdata(pdev, emc);
@@ -1244,6 +1248,11 @@ static int tegra_emc_probe(struct platform_device *pdev)
 		emc_debugfs_init(&pdev->dev, emc);
 
 	return 0;
+
+put_device:
+	put_device(&mc->dev);
+
+	return err;
 };
 
 static struct platform_driver tegra_emc_driver = {
diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c b/drivers/net/ethernet/freescale/fman/fman_port.c
index 9790e483241b..fcc59444df17 100644
--- a/drivers/net/ethernet/freescale/fman/fman_port.c
+++ b/drivers/net/ethernet/freescale/fman/fman_port.c
@@ -1792,7 +1792,7 @@ static int fman_port_probe(struct platform_device *of_dev)
 	if (!fm_node) {
 		dev_err(port->dev, "%s: of_get_parent() failed\n", __func__);
 		err = -ENODEV;
-		goto free_port;
+		goto put_node;
 	}
 
 	fm_pdev = of_find_device_by_node(fm_node);
@@ -1899,7 +1899,6 @@ static int fman_port_probe(struct platform_device *of_dev)
 	put_device(&fm_pdev->dev);
 put_node:
 	of_node_put(port_node);
-free_port:
 	kfree(port);
 	return err;
 }
-- 
2.25.4


  reply	other threads:[~2020-11-09 13:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-31 10:53 [PATCH] memory: tegra: add missing put_devcie() call in tegra_emc_probe() Yu Kuai
2020-11-02 18:52 ` Krzysztof Kozlowski
2020-11-09 13:28   ` Yu Kuai [this message]
2020-11-09 16:41     ` [PATCH V2] memory: tegra: add missing put_devcie() call in error path of tegra_emc_probe() Krzysztof Kozlowski
2020-11-10  1:33       ` [PATCH V3] memory: tegra: add missing put_device() " Yu Kuai
2020-11-10 15:21         ` Krzysztof Kozlowski
2020-11-11  1:11           ` yukuai (C)

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=20201109132847.1738010-1-yukuai3@huawei.com \
    --to=yukuai3@huawei.com \
    --cc=davem@davemloft.net \
    --cc=jonathanh@nvidia.com \
    --cc=krzk@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=madalin.bucur@nxp.com \
    --cc=mperttunen@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=tomeu.vizoso@collabora.com \
    --cc=yi.zhang@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).