summaryrefslogtreecommitdiff
path: root/drivers/cpufreq
diff options
context:
space:
mode:
authorJagadeesh Kona <quic_jkona@quicinc.com>2024-05-20 09:37:32 +0300
committerViresh Kumar <viresh.kumar@linaro.org>2024-05-28 07:01:09 +0300
commit074cffb5020ddcaa5fafcc55655e5da6ebe8c831 (patch)
treed88cc7f6ed617152333f97889fafa63e498ab2f7 /drivers/cpufreq
parentfa8036e5fed21d871aef23092990bfbaddc521d5 (diff)
downloadlinux-074cffb5020ddcaa5fafcc55655e5da6ebe8c831.tar.xz
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@quicinc.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r--drivers/cpufreq/scmi-cpufreq.c4
1 files 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;