Linux Power Management development
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Haotian Zhang <vulab@iscas.ac.cn>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
	Stephen Boyd <swboyd@chromium.org>,
	Taniya Das <taniya.das@oss.qualcomm.com>,
	Saravana Kannan <saravanak@kernel.org>,
	linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cpufreq: qcom-cpufreq-hw: fix device node refcount leak in phandle parsing
Date: Fri, 9 Oct 2026 10:02:59 +0530	[thread overview]
Message-ID: <ashueyfHcwGHziVG@vireshk-B250M-D3H> (raw)
In-Reply-To: <20261008172442.2725544-1-vulab@iscas.ac.cn>

On 09-10-26, 01:24, Haotian Zhang wrote:
> of_parse_phandle_with_args() transfers a reference to the provider node
> in out_args->np, which the caller is responsible for releasing with
> of_node_put().  Neither qcom_get_related_cpus() nor
> qcom_cpufreq_hw_cpu_init() ever puts args.np: they only put cpu_np, which
> is a different node obtained from of_cpu_device_node_get().  The
> reference is therefore leaked on every successful call, and
> qcom_get_related_cpus() leaks one per present CPU.
> 
> Release args.np after the parsed index has been read in both call sites.
> 
> Fixes: 2849dd8bc72b ("cpufreq: qcom-hw: Add support for QCOM cpufreq HW driver")
> Assisted-by: DeepSeek-V4.1-Flash
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
>  drivers/cpufreq/qcom-cpufreq-hw.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
> index 874ff3fb9d97..060a460716f7 100644
> --- a/drivers/cpufreq/qcom-cpufreq-hw.c
> +++ b/drivers/cpufreq/qcom-cpufreq-hw.c
> @@ -322,6 +322,8 @@ static void qcom_get_related_cpus(int index, struct cpumask *m)
>  
>  		if (index == args.args[0])
>  			cpumask_set_cpu(cpu, m);
> +
> +		of_node_put(args.np);
>  	}
>  }
>  
> @@ -554,6 +556,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
>  		return ret;
>  
>  	index = args.args[0];
> +	of_node_put(args.np);
>  	data = &qcom_cpufreq.data[index];
>  
>  	/* HW should be in enabled state to proceed */

Applied. Thanks.

-- 
viresh

      reply	other threads:[~2026-10-09  4:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08 17:24 [PATCH] cpufreq: qcom-cpufreq-hw: fix device node refcount leak in phandle parsing Haotian Zhang
2026-10-09  4:32 ` Viresh Kumar [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=ashueyfHcwGHziVG@vireshk-B250M-D3H \
    --to=viresh.kumar@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=saravanak@kernel.org \
    --cc=swboyd@chromium.org \
    --cc=taniya.das@oss.qualcomm.com \
    --cc=vulab@iscas.ac.cn \
    /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