Skip to content

Commit 074cffb

Browse files
Jagadeesh Konavireshk
authored andcommitted
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 <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent fa8036e commit 074cffb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/cpufreq/scmi-cpufreq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ static unsigned int scmi_cpufreq_fast_switch(struct cpufreq_policy *policy,
6363
unsigned int target_freq)
6464
{
6565
struct scmi_data *priv = policy->driver_data;
66+
unsigned long freq = target_freq;
6667

67-
if (!perf_ops->freq_set(ph, priv->domain_id,
68-
target_freq * 1000, true))
68+
if (!perf_ops->freq_set(ph, priv->domain_id, freq * 1000, true))
6969
return target_freq;
7070

7171
return 0;

0 commit comments

Comments
 (0)