* [PATCH] cpufreq: mediatek: fix device leak on probe failure
@ 2025-09-09 7:38 Johan Hovold
2025-09-09 8:01 ` AngeloGioacchino Del Regno
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Johan Hovold @ 2025-09-09 7:38 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar
Cc: Matthias Brugger, AngeloGioacchino Del Regno, linux-pm,
linux-mediatek, linux-kernel, Johan Hovold, Jia-Wei Chang,
Rex-BC Chen
Make sure to drop the reference to the cci device taken by
of_find_device_by_node() on probe failure (e.g. probe deferral).
Fixes: 0daa47325bae ("cpufreq: mediatek: Link CCI device to CPU")
Cc: Jia-Wei Chang <jia-wei.chang@mediatek.com>
Cc: Rex-BC Chen <rex-bc.chen@mediatek.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/cpufreq/mediatek-cpufreq.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/cpufreq/mediatek-cpufreq.c b/drivers/cpufreq/mediatek-cpufreq.c
index f3f02c4b6888..21537a05785d 100644
--- a/drivers/cpufreq/mediatek-cpufreq.c
+++ b/drivers/cpufreq/mediatek-cpufreq.c
@@ -404,9 +404,11 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
}
info->cpu_clk = clk_get(cpu_dev, "cpu");
- if (IS_ERR(info->cpu_clk))
- return dev_err_probe(cpu_dev, PTR_ERR(info->cpu_clk),
- "cpu%d: failed to get cpu clk\n", cpu);
+ if (IS_ERR(info->cpu_clk)) {
+ ret = PTR_ERR(info->cpu_clk);
+ dev_err_probe(cpu_dev, ret, "cpu%d: failed to get cpu clk\n", cpu);
+ goto out_put_cci_dev;
+ }
info->inter_clk = clk_get(cpu_dev, "intermediate");
if (IS_ERR(info->inter_clk)) {
@@ -552,6 +554,10 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
out_free_mux_clock:
clk_put(info->cpu_clk);
+out_put_cci_dev:
+ if (info->soc_data->ccifreq_supported)
+ put_device(info->cci_dev);
+
return ret;
}
@@ -569,6 +575,8 @@ static void mtk_cpu_dvfs_info_release(struct mtk_cpu_dvfs_info *info)
clk_put(info->inter_clk);
dev_pm_opp_of_cpumask_remove_table(&info->cpus);
dev_pm_opp_unregister_notifier(info->cpu_dev, &info->opp_nb);
+ if (info->soc_data->ccifreq_supported)
+ put_device(info->cci_dev);
}
static int mtk_cpufreq_init(struct cpufreq_policy *policy)
--
2.49.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] cpufreq: mediatek: fix device leak on probe failure
2025-09-09 7:38 [PATCH] cpufreq: mediatek: fix device leak on probe failure Johan Hovold
@ 2025-09-09 8:01 ` AngeloGioacchino Del Regno
2025-09-09 9:57 ` Chen-Yu Tsai
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-09-09 8:01 UTC (permalink / raw)
To: Johan Hovold, Rafael J. Wysocki, Viresh Kumar
Cc: Matthias Brugger, linux-pm, linux-mediatek, linux-kernel,
Jia-Wei Chang, Rex-BC Chen
Il 09/09/25 09:38, Johan Hovold ha scritto:
> Make sure to drop the reference to the cci device taken by
> of_find_device_by_node() on probe failure (e.g. probe deferral).
>
> Fixes: 0daa47325bae ("cpufreq: mediatek: Link CCI device to CPU")
> Cc: Jia-Wei Chang <jia-wei.chang@mediatek.com>
> Cc: Rex-BC Chen <rex-bc.chen@mediatek.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cpufreq: mediatek: fix device leak on probe failure
2025-09-09 7:38 [PATCH] cpufreq: mediatek: fix device leak on probe failure Johan Hovold
2025-09-09 8:01 ` AngeloGioacchino Del Regno
@ 2025-09-09 9:57 ` Chen-Yu Tsai
2025-09-09 10:03 ` Johan Hovold
2025-09-17 12:50 ` Johan Hovold
2025-09-29 9:11 ` Viresh Kumar
3 siblings, 1 reply; 6+ messages in thread
From: Chen-Yu Tsai @ 2025-09-09 9:57 UTC (permalink / raw)
To: Johan Hovold
Cc: Rafael J. Wysocki, Viresh Kumar, Matthias Brugger,
AngeloGioacchino Del Regno, linux-pm, linux-mediatek,
linux-kernel, Jia-Wei Chang, Rex-BC Chen
On Tue, Sep 9, 2025 at 5:40 PM Johan Hovold <johan@kernel.org> wrote:
>
> Make sure to drop the reference to the cci device taken by
> of_find_device_by_node() on probe failure (e.g. probe deferral).
>
> Fixes: 0daa47325bae ("cpufreq: mediatek: Link CCI device to CPU")
> Cc: Jia-Wei Chang <jia-wei.chang@mediatek.com>
> Cc: Rex-BC Chen <rex-bc.chen@mediatek.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
> drivers/cpufreq/mediatek-cpufreq.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cpufreq/mediatek-cpufreq.c b/drivers/cpufreq/mediatek-cpufreq.c
> index f3f02c4b6888..21537a05785d 100644
> --- a/drivers/cpufreq/mediatek-cpufreq.c
> +++ b/drivers/cpufreq/mediatek-cpufreq.c
> @@ -404,9 +404,11 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
> }
>
> info->cpu_clk = clk_get(cpu_dev, "cpu");
> - if (IS_ERR(info->cpu_clk))
> - return dev_err_probe(cpu_dev, PTR_ERR(info->cpu_clk),
> - "cpu%d: failed to get cpu clk\n", cpu);
> + if (IS_ERR(info->cpu_clk)) {
> + ret = PTR_ERR(info->cpu_clk);
> + dev_err_probe(cpu_dev, ret, "cpu%d: failed to get cpu clk\n", cpu);
> + goto out_put_cci_dev;
> + }
>
> info->inter_clk = clk_get(cpu_dev, "intermediate");
> if (IS_ERR(info->inter_clk)) {
> @@ -552,6 +554,10 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
> out_free_mux_clock:
> clk_put(info->cpu_clk);
>
> +out_put_cci_dev:
> + if (info->soc_data->ccifreq_supported)
> + put_device(info->cci_dev);
put_device() has a check for NULL, so the if isn't really needed.
Either way,
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
> +
> return ret;
> }
>
> @@ -569,6 +575,8 @@ static void mtk_cpu_dvfs_info_release(struct mtk_cpu_dvfs_info *info)
> clk_put(info->inter_clk);
> dev_pm_opp_of_cpumask_remove_table(&info->cpus);
> dev_pm_opp_unregister_notifier(info->cpu_dev, &info->opp_nb);
> + if (info->soc_data->ccifreq_supported)
> + put_device(info->cci_dev);
> }
>
> static int mtk_cpufreq_init(struct cpufreq_policy *policy)
> --
> 2.49.1
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cpufreq: mediatek: fix device leak on probe failure
2025-09-09 9:57 ` Chen-Yu Tsai
@ 2025-09-09 10:03 ` Johan Hovold
0 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2025-09-09 10:03 UTC (permalink / raw)
To: Chen-Yu Tsai
Cc: Rafael J. Wysocki, Viresh Kumar, Matthias Brugger,
AngeloGioacchino Del Regno, linux-pm, linux-mediatek,
linux-kernel, Jia-Wei Chang, Rex-BC Chen
On Tue, Sep 09, 2025 at 05:57:45PM +0800, Chen-Yu Tsai wrote:
> On Tue, Sep 9, 2025 at 5:40 PM Johan Hovold <johan@kernel.org> wrote:
> >
> > Make sure to drop the reference to the cci device taken by
> > of_find_device_by_node() on probe failure (e.g. probe deferral).
> > @@ -552,6 +554,10 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
> > out_free_mux_clock:
> > clk_put(info->cpu_clk);
> >
> > +out_put_cci_dev:
> > + if (info->soc_data->ccifreq_supported)
> > + put_device(info->cci_dev);
>
> put_device() has a check for NULL, so the if isn't really needed.
I know, but this follows the pattern currently used by the driver (e.g.
for regulator_put()) and avoids relying on the caller having cleared the
info struct.
> Either way,
>
> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Thanks for reviewing.
Johan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cpufreq: mediatek: fix device leak on probe failure
2025-09-09 7:38 [PATCH] cpufreq: mediatek: fix device leak on probe failure Johan Hovold
2025-09-09 8:01 ` AngeloGioacchino Del Regno
2025-09-09 9:57 ` Chen-Yu Tsai
@ 2025-09-17 12:50 ` Johan Hovold
2025-09-29 9:11 ` Viresh Kumar
3 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2025-09-17 12:50 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar
Cc: Matthias Brugger, AngeloGioacchino Del Regno, linux-pm,
linux-mediatek, linux-kernel, Jia-Wei Chang, Rex-BC Chen
On Tue, Sep 09, 2025 at 09:38:19AM +0200, Johan Hovold wrote:
> Make sure to drop the reference to the cci device taken by
> of_find_device_by_node() on probe failure (e.g. probe deferral).
>
> Fixes: 0daa47325bae ("cpufreq: mediatek: Link CCI device to CPU")
> Cc: Jia-Wei Chang <jia-wei.chang@mediatek.com>
> Cc: Rex-BC Chen <rex-bc.chen@mediatek.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Can this one be picked up for 6.18?
Johan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cpufreq: mediatek: fix device leak on probe failure
2025-09-09 7:38 [PATCH] cpufreq: mediatek: fix device leak on probe failure Johan Hovold
` (2 preceding siblings ...)
2025-09-17 12:50 ` Johan Hovold
@ 2025-09-29 9:11 ` Viresh Kumar
3 siblings, 0 replies; 6+ messages in thread
From: Viresh Kumar @ 2025-09-29 9:11 UTC (permalink / raw)
To: Johan Hovold
Cc: Rafael J. Wysocki, Matthias Brugger, AngeloGioacchino Del Regno,
linux-pm, linux-mediatek, linux-kernel, Jia-Wei Chang,
Rex-BC Chen
On 09-09-25, 09:38, Johan Hovold wrote:
> Make sure to drop the reference to the cci device taken by
> of_find_device_by_node() on probe failure (e.g. probe deferral).
>
> Fixes: 0daa47325bae ("cpufreq: mediatek: Link CCI device to CPU")
> Cc: Jia-Wei Chang <jia-wei.chang@mediatek.com>
> Cc: Rex-BC Chen <rex-bc.chen@mediatek.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
> drivers/cpufreq/mediatek-cpufreq.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
Applied. Thanks.
--
viresh
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-09-29 9:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-09 7:38 [PATCH] cpufreq: mediatek: fix device leak on probe failure Johan Hovold
2025-09-09 8:01 ` AngeloGioacchino Del Regno
2025-09-09 9:57 ` Chen-Yu Tsai
2025-09-09 10:03 ` Johan Hovold
2025-09-17 12:50 ` Johan Hovold
2025-09-29 9:11 ` Viresh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox