cpufreq: scmi/scpi: Fix NULL pointer dereference in get_rate()
Subsystems (2)
v2 cover cpufreq: scmi/scpi: Fix NULL pointer dereference in get_rate()
This series fixes potential NULL pointer dereferences in scmi_cpufreq_get_rate() and scpi_cpufreq_get_rate() when cpufreq_cpu_get_raw() returns NULL.
Henry Martin (2):
cpufreq: scmi: Fix null-ptr-deref in scmi_cpufreq_get_rate()
cpufreq: scpi: Fix null-ptr-deref in scpi_cpufreq_get_rate()
drivers/cpufreq/scmi-cpufreq.c | 10 ++++++++-- drivers/cpufreq/scpi-cpufreq.c | 13 ++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/2 cpufreq: scmi: Fix null-ptr-deref in scmi_cpufreq_get_rate()
cpufreq_cpu_get_raw() can return NULL when the target CPU is not present in the policy->cpus mask. scmi_cpufreq_get_rate() does not check for this case, which results in a NULL pointer dereference.
Add NULL check after cpufreq_cpu_get_raw() to prevent this issue.
---
V1 -> V2: Use if (unlikely(!policy)) instead of if (!policy)
drivers/cpufreq/scmi-cpufreq.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/cpufreq/scmi-cpufreq.c +8 -2
@@ -37,11 +37,17 @@ static struct cpufreq_driver scmi_cpufreq_driver;static unsigned int scmi_cpufreq_get_rate (unsigned int cpu) { -struct cpufreq_policy *policy =cpufreq_cpu_get_raw (cpu); -struct scmi_data *priv = policy->driver_data; +struct cpufreq_policy *policy; +struct scmi_data *priv;unsigned long rate;int ret; + policy =cpufreq_cpu_get_raw (cpu); +if (unlikely (!policy)) +return 0 ; + + priv = policy->driver_data; + ret = perf_ops->freq_get (ph, priv->domain_id, &rate, false);if (ret)return 0 ;
Signature · 1 line
2.34.1
PATCH v2 2/2 cpufreq: scpi: Fix null-ptr-deref in scpi_cpufreq_get_rate()
In reply to Henry Martincpufreq_cpu_get_raw() can return NULL when the target CPU is not present in the policy->cpus mask. scpi_cpufreq_get_rate() does not check for this case, which results in a NULL pointer dereference.
---
V1 -> V2: Use if (unlikely(!policy)) instead of if (!policy)
drivers/cpufreq/scpi-cpufreq.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/cpufreq/scpi-cpufreq.c +10 -3
@@ -29,9 +29,16 @@ static struct scpi_ops *scpi_ops;static unsigned int scpi_cpufreq_get_rate (unsigned int cpu) { -struct cpufreq_policy *policy =cpufreq_cpu_get_raw (cpu); -struct scpi_data *priv = policy->driver_data; -unsigned long rate =clk_get_rate (priv->clk); +struct cpufreq_policy *policy; +struct scpi_data *priv; +unsigned long rate; + + policy =cpufreq_cpu_get_raw (cpu); +if (unlikely (!policy)) +return 0 ; + + priv = policy->driver_data; + rate =clk_get_rate (priv->clk);return rate /1000 ; }
Signature · 1 line
2.34.1
Quoted 6 lines
This series fixes potential NULL pointer dereferences in
scmi_cpufreq_get_rate()andscpi_cpufreq_get_rate()whencpufreq_cpu_get_raw()returns NULL.Henry Martin (2):
cpufreq: scmi: Fix null-ptr-deref inscmi_cpufreq_get_rate()
cpufreq: scpi: Fix null-ptr-deref inscpi_cpufreq_get_rate()
Can any other summary phrase variants become more desirable accordingly?
Regards,
Markus
Quoted 9 lines · Markus Elfring
Quoted 6 lines
This series fixes potential NULL pointer dereferences in
scmi_cpufreq_get_rate()andscpi_cpufreq_get_rate()whencpufreq_cpu_get_raw()returns NULL.Henry Martin (2):
cpufreq: scmi: Fix null-ptr-deref inscmi_cpufreq_get_rate()
cpufreq: scpi: Fix null-ptr-deref inscpi_cpufreq_get_rate()Can any other summary phrase variants become more desirable accordingly?
This is meaningless, sorry can't parse. Ignoring it as others in the community are doing already.
Signature · 2 lines
Regards, Sudeep
Quoted 4 lines
Quoted 1 line
Can any other summary phrase variants become more desirable accordingly?
This is meaningless, sorry can't parse. Ignoring it as others in the community are doing already.
Do you care if the term “null pointer dereference” would be used in consistent ways?
Regards,
Markus
Cristian Marussi
reviewerQuoted 1 line · Markus Elfring
Quoted 1 line
Quoted 1 line
Can any other summary phrase variants become more desirable accordingly?
I agree with Sudeep, the above sentence is completely incomprehensible to me
Quoted 5 lines
Quoted 3 lines
This is meaningless, sorry can't parse. Ignoring it as others in the community are doing already.
Do you care if the term “null pointer dereference” would be used in consistent ways?
...this is more comprehensible, but again I cannot grasp what's yor advice specifically on this commit message.
Thanks,
Cristian
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Can any other summary phrase variants become more desirable accordingly?
I agree with Sudeep, the above sentence is completely incomprehensible to me
Can any suggestions gain acceptance also for better summary phrases?
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
This is meaningless, sorry can't parse. Ignoring it as others in the community are doing already.
Do you care if the term “null pointer dereference” would be used in consistent ways?
...this is more comprehensible,
Thanks for another bit of constructive information.
Quoted 2 lines
but again I cannot grasp what's yor advice
specifically on this commit message.
May the usage of abbreviations be reconsidered once more also for such messages (in presented update steps)?
Regards,
Markus
Quoted 15 lines · Markus Elfring
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Can any other summary phrase variants become more desirable accordingly?
I agree with Sudeep, the above sentence is completely incomprehensible to me
Can any suggestions gain acceptance also for better summary phrases?
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
This is meaningless, sorry can't parse. Ignoring it as others in the community are doing already.
Do you care if the term “null pointer dereference” would be used in consistent ways?
...this is more comprehensible,
Quoted 8 lines
Thanks for another bit of constructive information.
Quoted 2 lines
but again I cannot grasp what's yor advice
specifically on this commit message.May the usage of abbreviations be reconsidered once more also for such messages (in presented update steps)?
Still can't understand you. Sorry for that. Alternatively, you can do what I sometimes do: just write the whole commit log as you would expect and see if that helps. I am sure that helps, so please do that.
Signature · 2 lines
Regards, Sudeep
Quoted 4 lines
Quoted 2 lines
May the usage of abbreviations be reconsidered once more also for such messages (in presented update steps)?
Still can't understand you. Sorry for that. …
Will any communication challenges need further clarifications also according to wordings like the following?
* null-ptr-deref
* null pointer dereference
Regards,
Markus
Quoted 3 lines · Henry Martin
This series fixes potential NULL pointer dereferences in
scmi_cpufreq_get_rate()andscpi_cpufreq_get_rate()whencpufreq_cpu_get_raw()returns NULL.
I think unlikely is needed even in this patch[1] and thats what Viresh meant when he mention all similar changes under one series and consistent change.
Also I just happened to notice similar patches posted while ago[2][3]. Not sure how to handle the situation though.
Signature · 6 lines
Regards, Sudeep [1] https://lore.kernel.org/all/[email protected]/ [2] https://lore.kernel.org/all/[email protected] [3] https://lore.kernel.org/all/[email protected]
Quoted 3 lines
I think unlikely is needed even in this patch[1] and thats what Viresh meant when he mention all similar changes under one series and consistent change.
Thanks for reviewing. I'll send v2 of patch[1] soon.
Quoted 22 lines · Sudeep Holla <[email protected]> 于2025年4月9日周三 19:30写道:
Quoted 3 lines · Henry Martin
This series fixes potential NULL pointer dereferences in
scmi_cpufreq_get_rate()andscpi_cpufreq_get_rate()whencpufreq_cpu_get_raw()returns NULL.Acked-by Sudeep Holla <[email protected]>I think unlikely is needed even in this patch[1] and thats what Viresh meant when he mention all similar changes under one series and consistent change.
Also I just happened to notice similar patches posted while ago[2][3]. Not sure how to handle the situation though.
--
Regards,
Sudeep[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]
[3] https://lore.kernel.org/all/[email protected]
Quoted 10 lines · Henry Martin
This series fixes potential NULL pointer dereferences in
scmi_cpufreq_get_rate()andscpi_cpufreq_get_rate()whencpufreq_cpu_get_raw()returns NULL.Henry Martin (2):
cpufreq: scmi: Fix null-ptr-deref inscmi_cpufreq_get_rate()
cpufreq: scpi: Fix null-ptr-deref inscpi_cpufreq_get_rate()drivers/cpufreq/scmi-cpufreq.c | 10 ++++++++-- drivers/cpufreq/scpi-cpufreq.c | 13 ++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-)
Applied. Thanks.
Signature · 1 line
viresh