linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix some wrong goto jumps for avoiding memory leak.
@ 2021-06-09 14:22 zpershuai
  2021-06-12 19:57 ` Martin Blumenstingl
  0 siblings, 1 reply; 2+ messages in thread
From: zpershuai @ 2021-06-09 14:22 UTC (permalink / raw)
  To: Mark Brown, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, linux-spi, linux-arm-kernel, linux-amlogic,
	linux-kernel
  Cc: zpershuai

In meson_spifc_probe function, when  enable the device pclk clock is
error, it should use clk_disable_unprepare to release the core clock.

And when meson_spicc_clk_init returns failed,  it should goto the
out_clk label.

Signed-off-by: zpershuai <zpershuai@gmail.com>
---
 drivers/spi/spi-meson-spicc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c
index ecba6b4..b2c4621 100644
--- a/drivers/spi/spi-meson-spicc.c
+++ b/drivers/spi/spi-meson-spicc.c
@@ -725,7 +725,7 @@ static int meson_spicc_probe(struct platform_device *pdev)
 	ret = clk_prepare_enable(spicc->pclk);
 	if (ret) {
 		dev_err(&pdev->dev, "pclk clock enable failed\n");
-		goto out_master;
+		goto out_core_clk;
 	}
 
 	device_reset_optional(&pdev->dev);
@@ -752,7 +752,7 @@ static int meson_spicc_probe(struct platform_device *pdev)
 	ret = meson_spicc_clk_init(spicc);
 	if (ret) {
 		dev_err(&pdev->dev, "clock registration failed\n");
-		goto out_master;
+		goto out_clk;
 	}
 
 	ret = devm_spi_register_master(&pdev->dev, master);
@@ -764,9 +764,11 @@ static int meson_spicc_probe(struct platform_device *pdev)
 	return 0;
 
 out_clk:
-	clk_disable_unprepare(spicc->core);
 	clk_disable_unprepare(spicc->pclk);
 
+out_core_clk:
+	clk_disable_unprepare(spicc->core);
+
 out_master:
 	spi_master_put(master);
 
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] Fix some wrong goto jumps for avoiding memory leak.
  2021-06-09 14:22 [PATCH] Fix some wrong goto jumps for avoiding memory leak zpershuai
@ 2021-06-12 19:57 ` Martin Blumenstingl
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Blumenstingl @ 2021-06-12 19:57 UTC (permalink / raw)
  To: zpershuai
  Cc: Mark Brown, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	linux-spi, linux-arm-kernel, linux-amlogic, linux-kernel

Hello,

On Wed, Jun 9, 2021 at 4:22 PM zpershuai <zpershuai@gmail.com> wrote:
>
> In meson_spifc_probe function, when  enable the device pclk clock is
> error, it should use clk_disable_unprepare to release the core clock.
>
> And when meson_spicc_clk_init returns failed,  it should goto the
> out_clk label.
After reviewing your patch I agree with your findings!
So thank you very much for bringing this up and sending a fix

The subject of this patch does not match what we usually have
Can you please make it start with "spi: meson-spicc:" (see git log
drivers/spi/spi-meson-spicc.c)

[...]
>         device_reset_optional(&pdev->dev);
> @@ -752,7 +752,7 @@ static int meson_spicc_probe(struct platform_device *pdev)
>         ret = meson_spicc_clk_init(spicc);
>         if (ret) {
>                 dev_err(&pdev->dev, "clock registration failed\n");
> -               goto out_master;
> +               goto out_clk;
>         }
I'd prefer this part to go into a separate patch so that separate
patch can get the following Fixes tag (which should then be added
above your Signed-off-by):
Fixes: 3e0cf4d3fc29 ("spi: meson-spicc: add a linear clock divider support")

The remaining changes (to my understanding) should get:
Fixes: 454fa271bc4e ("spi: Add Meson SPICC driver")

The "Fixes" tag is relevant so bug-fixes can be backported to older
kernel versions automatically.

So it would be great if you could send a second version with the above
changes considered.


Thank you and best regards,
Martin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-06-12 19:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 14:22 [PATCH] Fix some wrong goto jumps for avoiding memory leak zpershuai
2021-06-12 19:57 ` Martin Blumenstingl

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