mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
To: Haoxiang Li <haoxiang_li2024@163.com>,
	rafael@kernel.org, viresh.kumar@linaro.org, deepak.sikri@st.com
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
Subject: Re: [PATCH] cpufreq: spear: Fix clock reference leak in spear_cpufreq_target()
Date: Wed, 18 Nov 2026 14:54:58 +0800	[thread overview]
Message-ID: <3af8a03e-137a-456f-b1de-626405852482@oss.qualcomm.com> (raw)
In-Reply-To: <20261118053229.2066011-1-haoxiang_li2024@163.com>

On 11/18/2026 1:32 PM, Haoxiang Li wrote:
> spear1340_cpu_get_possible_parent() acquires a clock reference with
> clk_get() for each frequency transition. However,spear_cpufreq_target()

Nit: missing space after the comma.

> never releases this reference, leaking a clock consumer object and its
> reference on both success and error paths. Add a common cleanup path to
> release the source clock reference.
> 
> Fixes: 420993221175 ("cpufreq: SPEAr: Add CPUFreq driver")
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>


Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com> (with a nit
inline)

> ---
>   drivers/cpufreq/spear-cpufreq.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
> index ffe5eda82f0b..7f3fd6eca854 100644
> --- a/drivers/cpufreq/spear-cpufreq.c
> +++ b/drivers/cpufreq/spear-cpufreq.c
> @@ -136,7 +136,8 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy,
>   	newfreq = clk_round_rate(srcclk, newfreq * mult);
>   	if (newfreq <= 0) {
>   		pr_err("clk_round_rate failed for cpu src clock\n");
> -		return newfreq;
> +		ret = newfreq;
> +		goto err_put;
>   	}
>   
>   	if (mult == 2)
> @@ -147,6 +148,9 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy,
>   	if (ret)
>   		pr_err("CPU Freq: cpu clk_set_rate failed: %d\n", ret);
>   
> +err_put:

Nit: this label is also reached on the success path, so something like
"out_put_clk" would be a more accurate name than "err_put".

> +	if (mult == 2)
> +		clk_put(srcclk);
>   	return ret;
>   }
>   


-- 
Thx and BRs,
Zhongqiu Han

      reply	other threads:[~2026-11-18  6:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  5:32 Haoxiang Li
2026-11-18  6:54 ` Zhongqiu Han [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3af8a03e-137a-456f-b1de-626405852482@oss.qualcomm.com \
    --to=zhongqiu.han@oss.qualcomm.com \
    --cc=deepak.sikri@st.com \
    --cc=haoxiang_li2024@163.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®