Fix some wrong goto jumps for avoiding memory leak.
Subsystems (2)
PATCH 1/1 Fix some wrong goto jumps for avoiding memory leak.
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.
--- drivers/spi/spi-meson-spicc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/spi/spi-meson-spicc.c +5 -3
@@ -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);
Signature · 1 line
2.7.4
Martin Blumenstingl
reviewerHello,
Quoted 6 lines · zpershuai
In
meson_spifc_probefunction, when enable the device pclk clock is error, it should useclk_disable_unprepareto release the core clock.And when
meson_spicc_clk_initreturns failed, it should goto theout_clklabel.
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)
[...]
drivers/spi/spi-meson-spicc.c static int meson_spicc_probe(struct platform_device *pdev) · line 756
Quoted 8 lines
device_reset_optional(&pdev->dev);drivers/spi/spi-meson-spicc.c +1
-1@@ -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):
The remaining changes (to my understanding) should get:
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