[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240520063732.11220-1-quic_jkona@quicinc.com>
Date: Mon, 20 May 2024 12:07:32 +0530
From: Jagadeesh Kona <quic_jkona@...cinc.com>
To: Sudeep Holla <sudeep.holla@....com>,
Viresh Kumar
<viresh.kumar@...aro.org>,
"Rafael J . Wysocki" <rafael@...nel.org>,
"Cristian Marussi" <cristian.marussi@....com>
CC: <linux-arm-kernel@...ts.infradead.org>, <linux-pm@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, Taniya Das <quic_tdas@...cinc.com>,
"Ajit
Pandey" <quic_ajipan@...cinc.com>,
Imran Shaik <quic_imrashai@...cinc.com>,
Vivek Aknurwar <quic_viveka@...cinc.com>,
Mike Tipton
<quic_mdtipton@...cinc.com>,
Jagadeesh Kona <quic_jkona@...cinc.com>
Subject: [PATCH V2] cpufreq: scmi: Avoid overflow of target_freq in fast switch
Conversion of target_freq to HZ in scmi_cpufreq_fast_switch()
can lead to overflow if the multiplied result is greater than
UINT_MAX, since type of target_freq is unsigned int. Avoid this
overflow by assigning target_freq to unsigned long variable for
converting it to HZ.
Signed-off-by: Jagadeesh Kona <quic_jkona@...cinc.com>
---
Changes in V2:
- Updated freq variable from u64 to unsigned long to keep it
consistent with the rate parameter in scmi .freq_set() callback
- Link to v1: https://lore.kernel.org/all/20240517070157.19553-1-quic_jkona@quicinc.com/
---
drivers/cpufreq/scmi-cpufreq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index 3b4f6bfb2f4c..b87fd127aa43 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -63,9 +63,9 @@ static unsigned int scmi_cpufreq_fast_switch(struct cpufreq_policy *policy,
unsigned int target_freq)
{
struct scmi_data *priv = policy->driver_data;
+ unsigned long freq = target_freq;
- if (!perf_ops->freq_set(ph, priv->domain_id,
- target_freq * 1000, true))
+ if (!perf_ops->freq_set(ph, priv->domain_id, freq * 1000, true))
return target_freq;
return 0;
--
2.43.0
Powered by blists - more mailing lists