* [PATCH] clk: mediatek: mt6735-apmixedsys: Fix an error handling path in clk_mt6735_apmixed_probe()
@ 2024-10-25 15:46 Christophe JAILLET
2024-11-01 9:01 ` Yassine Oudjana
2024-11-14 20:51 ` Stephen Boyd
0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2024-10-25 15:46 UTC (permalink / raw)
To: Yassine Oudjana, Michael Turquette, Stephen Boyd,
Matthias Brugger, AngeloGioacchino Del Regno
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-clk,
linux-mediatek, linux-arm-kernel
If an error occurs after a successful mtk_alloc_clk_data(),
mtk_free_clk_data() should be called, as already done in the .remove()
function.
Switch to mtk_devm_alloc_clk_data() in order to fix the memory leak in the
probe function, and simplify the remove function.
Fixes: 43c04ed79189 ("clk: mediatek: Add drivers for MediaTek MT6735 main clock and reset drivers")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only
---
drivers/clk/mediatek/clk-mt6735-apmixedsys.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/clk/mediatek/clk-mt6735-apmixedsys.c b/drivers/clk/mediatek/clk-mt6735-apmixedsys.c
index 104722a61dfd..e0949911e8f7 100644
--- a/drivers/clk/mediatek/clk-mt6735-apmixedsys.c
+++ b/drivers/clk/mediatek/clk-mt6735-apmixedsys.c
@@ -88,7 +88,7 @@ static int clk_mt6735_apmixed_probe(struct platform_device *pdev)
if (IS_ERR(base))
return PTR_ERR(base);
- clk_data = mtk_alloc_clk_data(ARRAY_SIZE(apmixedsys_plls));
+ clk_data = mtk_devm_alloc_clk_data(&pdev->dev, ARRAY_SIZE(apmixedsys_plls));
if (!clk_data)
return -ENOMEM;
platform_set_drvdata(pdev, clk_data);
@@ -114,7 +114,6 @@ static void clk_mt6735_apmixed_remove(struct platform_device *pdev)
struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
mtk_clk_unregister_plls(apmixedsys_plls, ARRAY_SIZE(apmixedsys_plls), clk_data);
- mtk_free_clk_data(clk_data);
}
static const struct of_device_id of_match_mt6735_apmixedsys[] = {
--
2.47.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: mediatek: mt6735-apmixedsys: Fix an error handling path in clk_mt6735_apmixed_probe()
2024-10-25 15:46 [PATCH] clk: mediatek: mt6735-apmixedsys: Fix an error handling path in clk_mt6735_apmixed_probe() Christophe JAILLET
@ 2024-11-01 9:01 ` Yassine Oudjana
2024-11-14 20:51 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Yassine Oudjana @ 2024-11-01 9:01 UTC (permalink / raw)
To: Christophe JAILLET, Michael Turquette, Stephen Boyd,
Matthias Brugger, AngeloGioacchino Del Regno
Cc: linux-kernel, kernel-janitors, linux-clk, linux-mediatek,
linux-arm-kernel
On 25/10/2024 6:46 pm, Christophe JAILLET wrote:
> If an error occurs after a successful mtk_alloc_clk_data(),
> mtk_free_clk_data() should be called, as already done in the .remove()
> function.
>
> Switch to mtk_devm_alloc_clk_data() in order to fix the memory leak in the
> probe function, and simplify the remove function.
>
> Fixes: 43c04ed79189 ("clk: mediatek: Add drivers for MediaTek MT6735 main clock and reset drivers")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only
> ---
> drivers/clk/mediatek/clk-mt6735-apmixedsys.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/clk/mediatek/clk-mt6735-apmixedsys.c b/drivers/clk/mediatek/clk-mt6735-apmixedsys.c
> index 104722a61dfd..e0949911e8f7 100644
> --- a/drivers/clk/mediatek/clk-mt6735-apmixedsys.c
> +++ b/drivers/clk/mediatek/clk-mt6735-apmixedsys.c
> @@ -88,7 +88,7 @@ static int clk_mt6735_apmixed_probe(struct platform_device *pdev)
> if (IS_ERR(base))
> return PTR_ERR(base);
>
> - clk_data = mtk_alloc_clk_data(ARRAY_SIZE(apmixedsys_plls));
> + clk_data = mtk_devm_alloc_clk_data(&pdev->dev, ARRAY_SIZE(apmixedsys_plls));
> if (!clk_data)
> return -ENOMEM;
> platform_set_drvdata(pdev, clk_data);
> @@ -114,7 +114,6 @@ static void clk_mt6735_apmixed_remove(struct platform_device *pdev)
> struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
>
> mtk_clk_unregister_plls(apmixedsys_plls, ARRAY_SIZE(apmixedsys_plls), clk_data);
> - mtk_free_clk_data(clk_data);
> }
>
> static const struct of_device_id of_match_mt6735_apmixedsys[] = {
> --
> 2.47.0
>
Thanks for the fix!
Tested-by: Yassine Oudjana <y.oudjana@protonmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: mediatek: mt6735-apmixedsys: Fix an error handling path in clk_mt6735_apmixed_probe()
2024-10-25 15:46 [PATCH] clk: mediatek: mt6735-apmixedsys: Fix an error handling path in clk_mt6735_apmixed_probe() Christophe JAILLET
2024-11-01 9:01 ` Yassine Oudjana
@ 2024-11-14 20:51 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2024-11-14 20:51 UTC (permalink / raw)
To: AngeloGioacchino Del Regno, Christophe JAILLET, Matthias Brugger,
Michael Turquette, Yassine Oudjana
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-clk,
linux-mediatek, linux-arm-kernel
Quoting Christophe JAILLET (2024-10-25 08:46:08)
> If an error occurs after a successful mtk_alloc_clk_data(),
> mtk_free_clk_data() should be called, as already done in the .remove()
> function.
>
> Switch to mtk_devm_alloc_clk_data() in order to fix the memory leak in the
> probe function, and simplify the remove function.
>
> Fixes: 43c04ed79189 ("clk: mediatek: Add drivers for MediaTek MT6735 main clock and reset drivers")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
Applied to clk-next
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-14 20:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-25 15:46 [PATCH] clk: mediatek: mt6735-apmixedsys: Fix an error handling path in clk_mt6735_apmixed_probe() Christophe JAILLET
2024-11-01 9:01 ` Yassine Oudjana
2024-11-14 20:51 ` Stephen Boyd
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).