* [PATCH] clk: fsl-sai: fix memory leak
@ 2020-11-01 18:48 Michael Walle
2020-11-05 0:29 ` Stephen Boyd
0 siblings, 1 reply; 3+ messages in thread
From: Michael Walle @ 2020-11-01 18:48 UTC (permalink / raw)
To: linux-clk, linux-kernel; +Cc: Michael Turquette, Stephen Boyd, Michael Walle
If the device is removed we don't unregister the composite clock. Fix
that.
Fixes: 9cd10205227c ("clk: fsl-sai: new driver")
Signed-off-by: Michael Walle <michael@walle.cc>
---
drivers/clk/clk-fsl-sai.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/clk/clk-fsl-sai.c b/drivers/clk/clk-fsl-sai.c
index 0221180a4dd7..1e81c8d8a6fd 100644
--- a/drivers/clk/clk-fsl-sai.c
+++ b/drivers/clk/clk-fsl-sai.c
@@ -68,9 +68,20 @@ static int fsl_sai_clk_probe(struct platform_device *pdev)
if (IS_ERR(hw))
return PTR_ERR(hw);
+ platform_set_drvdata(pdev, hw);
+
return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw);
}
+static int fsl_sai_clk_remove(struct platform_device *pdev)
+{
+ struct clk_hw *hw = platform_get_drvdata(pdev);
+
+ clk_hw_unregister_composite(hw);
+
+ return 0;
+}
+
static const struct of_device_id of_fsl_sai_clk_ids[] = {
{ .compatible = "fsl,vf610-sai-clock" },
{ }
@@ -79,6 +90,7 @@ MODULE_DEVICE_TABLE(of, of_fsl_sai_clk_ids);
static struct platform_driver fsl_sai_clk_driver = {
.probe = fsl_sai_clk_probe,
+ .remove = fsl_sai_clk_remove,
.driver = {
.name = "fsl-sai-clk",
.of_match_table = of_fsl_sai_clk_ids,
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: fsl-sai: fix memory leak
2020-11-01 18:48 [PATCH] clk: fsl-sai: fix memory leak Michael Walle
@ 2020-11-05 0:29 ` Stephen Boyd
2020-11-05 7:50 ` Michael Walle
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Boyd @ 2020-11-05 0:29 UTC (permalink / raw)
To: Michael Walle, linux-clk, linux-kernel; +Cc: Michael Turquette, Michael Walle
Quoting Michael Walle (2020-11-01 10:48:18)
> diff --git a/drivers/clk/clk-fsl-sai.c b/drivers/clk/clk-fsl-sai.c
> index 0221180a4dd7..1e81c8d8a6fd 100644
> --- a/drivers/clk/clk-fsl-sai.c
> +++ b/drivers/clk/clk-fsl-sai.c
> @@ -68,9 +68,20 @@ static int fsl_sai_clk_probe(struct platform_device *pdev)
> if (IS_ERR(hw))
> return PTR_ERR(hw);
>
> + platform_set_drvdata(pdev, hw);
> +
> return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw);
> }
>
> +static int fsl_sai_clk_remove(struct platform_device *pdev)
> +{
> + struct clk_hw *hw = platform_get_drvdata(pdev);
> +
> + clk_hw_unregister_composite(hw);
Should we add a devm_clk_hw_register_composite() API and use it here?
That way we don't need a remove function and devm can be used
throughout.
> +
> + return 0;
> +}
> +
> static const struct of_device_id of_fsl_sai_clk_ids[] = {
> { .compatible = "fsl,vf610-sai-clock" },
> { }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: fsl-sai: fix memory leak
2020-11-05 0:29 ` Stephen Boyd
@ 2020-11-05 7:50 ` Michael Walle
0 siblings, 0 replies; 3+ messages in thread
From: Michael Walle @ 2020-11-05 7:50 UTC (permalink / raw)
To: Stephen Boyd; +Cc: linux-clk, linux-kernel, Michael Turquette
Am 2020-11-05 01:29, schrieb Stephen Boyd:
> Quoting Michael Walle (2020-11-01 10:48:18)
>> diff --git a/drivers/clk/clk-fsl-sai.c b/drivers/clk/clk-fsl-sai.c
>> index 0221180a4dd7..1e81c8d8a6fd 100644
>> --- a/drivers/clk/clk-fsl-sai.c
>> +++ b/drivers/clk/clk-fsl-sai.c
>> @@ -68,9 +68,20 @@ static int fsl_sai_clk_probe(struct platform_device
>> *pdev)
>> if (IS_ERR(hw))
>> return PTR_ERR(hw);
>>
>> + platform_set_drvdata(pdev, hw);
>> +
>> return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
>> hw);
>> }
>>
>> +static int fsl_sai_clk_remove(struct platform_device *pdev)
>> +{
>> + struct clk_hw *hw = platform_get_drvdata(pdev);
>> +
>> + clk_hw_unregister_composite(hw);
>
> Should we add a devm_clk_hw_register_composite() API and use it here?
> That way we don't need a remove function and devm can be used
> throughout.
Can do. But does adding a devm_ function qualify for the -stable branch?
Or should I expect to have exactly this patch as a backport there then?
-michael
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-05 7:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-01 18:48 [PATCH] clk: fsl-sai: fix memory leak Michael Walle
2020-11-05 0:29 ` Stephen Boyd
2020-11-05 7:50 ` Michael Walle
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).