linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memory: tegra: add missing put_devcie() call in tegra_emc_probe()
@ 2020-10-31 10:53 Yu Kuai
  2020-11-02 18:52 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 7+ messages in thread
From: Yu Kuai @ 2020-10-31 10:53 UTC (permalink / raw)
  To: krzk, thierry.reding, jonathanh, mperttunen, tomeu.vizoso
  Cc: linux-kernel, linux-tegra, yukuai3, yi.zhang

if of_find_device_by_node() succeed, tegra_emc_probe() doesn't have a
corresponding put_device(). 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 | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/memory/tegra/tegra124-emc.c b/drivers/memory/tegra/tegra124-emc.c
index 76ace42a688a..831dfca0804c 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,9 @@ 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 = {
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] memory: tegra: add missing put_devcie() call in tegra_emc_probe()
  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   ` [PATCH V2] memory: tegra: add missing put_devcie() call in error path of tegra_emc_probe() Yu Kuai
  0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2020-11-02 18:52 UTC (permalink / raw)
  To: Yu Kuai
  Cc: thierry.reding, jonathanh, mperttunen, tomeu.vizoso,
	linux-kernel, linux-tegra, yi.zhang

On Sat, Oct 31, 2020 at 06:53:55PM +0800, Yu Kuai wrote:
> if of_find_device_by_node() succeed, tegra_emc_probe() doesn't have a
> corresponding put_device(). Thus add jump target to fix the exception
> handling for this function implementation.

Please fix the title in subject and reword, it's not possible to
understand it. You are fixing here error paths, so for example:

"The reference to device obtained with of_find_device_by_node() should
be dropped. Add missing put_device() calls in probe error paths.

> 
> Fixes: 73a7f0a90641("memory: tegra: Add EMC (external memory controller) driver")
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>  drivers/memory/tegra/tegra124-emc.c | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/memory/tegra/tegra124-emc.c b/drivers/memory/tegra/tegra124-emc.c
> index 76ace42a688a..831dfca0804c 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,9 @@ static int tegra_emc_probe(struct platform_device *pdev)
>  		emc_debugfs_init(&pdev->dev, emc);
>  
>  	return 0;

Line break

> +put_device:
> +	put_device(&mc->dev);

Line break

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH V2] memory: tegra: add missing put_devcie() call in error path of tegra_emc_probe()
  2020-11-02 18:52 ` Krzysztof Kozlowski
@ 2020-11-09 13:28   ` Yu Kuai
  2020-11-09 16:41     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 7+ messages in thread
From: Yu Kuai @ 2020-11-09 13:28 UTC (permalink / raw)
  To: krzk, thierry.reding, jonathanh, madalin.bucur, davem, kuba,
	mperttunen, tomeu.vizoso
  Cc: linux-kernel, linux-tegra, netdev, yukuai3, yi.zhang

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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH V2] memory: tegra: add missing put_devcie() call in error path of tegra_emc_probe()
  2020-11-09 13:28   ` [PATCH V2] memory: tegra: add missing put_devcie() call in error path of tegra_emc_probe() Yu Kuai
@ 2020-11-09 16:41     ` Krzysztof Kozlowski
  2020-11-10  1:33       ` [PATCH V3] memory: tegra: add missing put_device() " Yu Kuai
  0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2020-11-09 16:41 UTC (permalink / raw)
  To: Yu Kuai
  Cc: thierry.reding, jonathanh, madalin.bucur, davem, kuba,
	mperttunen, tomeu.vizoso, linux-kernel, linux-tegra, netdev,
	yi.zhang

On Mon, Nov 09, 2020 at 09:28:47PM +0800, Yu Kuai wrote:
> 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.

You still need to correct the typo devcie->device in subject, as in v1.

> 
> 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 +--

Changes in net are not related, please split... although actually I
think the issue is already fixed by 1f1997eb44b1 ("memory: tegra: Add
and use devm_tegra_memory_controller_get()").

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH V3] memory: tegra: add missing put_device() call in error path of tegra_emc_probe()
  2020-11-09 16:41     ` Krzysztof Kozlowski
@ 2020-11-10  1:33       ` Yu Kuai
  2020-11-10 15:21         ` Krzysztof Kozlowski
  0 siblings, 1 reply; 7+ messages in thread
From: Yu Kuai @ 2020-11-10  1:33 UTC (permalink / raw)
  To: krzk, thierry.reding, jonathanh, mperttunen, tomeu.vizoso
  Cc: linux-kernel, linux-tegra, yukuai3, yi.zhang, zhangxiaoxu5

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 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 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 = {
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH V3] memory: tegra: add missing put_device() call in error path of tegra_emc_probe()
  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)
  0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2020-11-10 15:21 UTC (permalink / raw)
  To: Yu Kuai
  Cc: thierry.reding, jonathanh, mperttunen, tomeu.vizoso,
	linux-kernel, linux-tegra, yi.zhang, zhangxiaoxu5

On Tue, Nov 10, 2020 at 09:33:11AM +0800, Yu Kuai wrote:
> 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 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)

I think you missed my previous comment about the issue being fixed
already.  Are you sure you rebased this on top of latest next?

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH V3] memory: tegra: add missing put_device() call in error path of tegra_emc_probe()
  2020-11-10 15:21         ` Krzysztof Kozlowski
@ 2020-11-11  1:11           ` yukuai (C)
  0 siblings, 0 replies; 7+ messages in thread
From: yukuai (C) @ 2020-11-11  1:11 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: thierry.reding, jonathanh, mperttunen, tomeu.vizoso,
	linux-kernel, linux-tegra, yi.zhang, zhangxiaoxu5

On 2020/11/10 23:21, Krzysztof Kozlowski wrote:
> On Tue, Nov 10, 2020 at 09:33:11AM +0800, Yu Kuai wrote:
>> 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 +++++++++++++++------
>>   1 file changed, 15 insertions(+), 6 deletions(-)
> 
> I think you missed my previous comment about the issue being fixed
> already.  Are you sure you rebased this on top of latest next?
> 

Hi,

It's true the issue was fixed.

Thanks,
Yu Kuai
> Best regards,
> Krzysztof
> .
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-11-11  1:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [PATCH V2] memory: tegra: add missing put_devcie() call in error path of tegra_emc_probe() Yu Kuai
2020-11-09 16:41     ` 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)

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).