From: "Li,Rongqing" <lirongqing@baidu.com>
To: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>
Subject: 答复: [外部邮件] Re: [PATCH] cpufreq: acpi-cpufreq: add NULL check for acpi_perf_data before freeing
Date: Wed, 12 Aug 2026 12:06:12 +0000 [thread overview]
Message-ID: <342485f49c66426c930d38fa19718ba1@baidu.com> (raw)
In-Reply-To: <3c7c27f1-8ccd-4b1a-a21e-9bde219bd9d0@oss.qualcomm.com>
> >
> > If alloc_percpu() fails in acpi_cpufreq_early_init(), acpi_perf_data
> > is NULL. Calling free_acpi_perf_data() will execute per_cpu_ptr(NULL,
> > i), which does not return NULL but an offset pointer.
>
> Hi RongQing,
>
> Could you please confirm if acpi_perf_data() can ever be executed when
> alloc_percpu() fails?
You are right, acpi_perf_data() can not be called when alloc_percpu() fails
Please drop this patch
thanks
[Li,Rongqing]
>
>
> > Dereferencing ->shared_cpu_map on this invalid pointer leads to a kernel
> > crash.
> >
> > Fix these issues by adding a NULL check at the start of
> > free_acpi_perf_data() and setting acpi_perf_data to NULL after freeing.
> >
> > Signed-off-by: Li RongQing <lirongqing@baidu.com>
> > ---
> > drivers/cpufreq/acpi-cpufreq.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> > index 87e4923..cd2ca87 100644
> > --- a/drivers/cpufreq/acpi-cpufreq.c
> > +++ b/drivers/cpufreq/acpi-cpufreq.c
> > @@ -517,11 +517,14 @@ static void free_acpi_perf_data(void)
> > {
> > unsigned int i;
> >
> > - /* Freeing a NULL pointer is OK, and alloc_percpu zeroes. */
> > + if (!acpi_perf_data)
> > + return;
> > +
> > for_each_possible_cpu(i)
> > free_cpumask_var(per_cpu_ptr(acpi_perf_data, i)
> > ->shared_cpu_map);
> > free_percpu(acpi_perf_data);
> > + acpi_perf_data = NULL;
> > }
> >
> > static int cpufreq_boost_down_prep(unsigned int cpu)
>
>
> --
> Thx and BRs,
> Zhongqiu Han
prev parent reply other threads:[~2026-08-12 12:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 6:10 [PATCH] cpufreq: acpi-cpufreq: add NULL check for acpi_perf_data before freeing lirongqing
2026-08-10 6:10 ` [PATCH] cpufreq: acpi-cpufreq: Initialize cmd.val in drv_read() lirongqing
2026-08-10 12:15 ` Zhongqiu Han
2026-08-10 6:10 ` [PATCH] cpufreq: acpi-cpufreq: Using cpufreq_for_each_entry() to iterate in extract_io() lirongqing
2026-08-12 13:59 ` Zhongqiu Han
2026-08-10 11:21 ` [PATCH] cpufreq: acpi-cpufreq: add NULL check for acpi_perf_data before freeing Zhongqiu Han
2026-08-10 11:52 ` Zhongqiu Han
2026-08-12 12:06 ` Li,Rongqing [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=342485f49c66426c930d38fa19718ba1@baidu.com \
--to=lirongqing@baidu.com \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=zhongqiu.han@oss.qualcomm.com \
/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