Skip to content

Commit d4955c0

Browse files
Sergey Shtylyovwilldeacon
authored andcommitted
arm64: topology: fix possible overflow in amu_fie_setup()
cpufreq_get_hw_max_freq() returns max frequency in kHz as *unsigned int*, while freq_inv_set_max_ratio() gets passed this frequency in Hz as 'u64'. Multiplying max frequency by 1000 can potentially result in overflow -- multiplying by 1000ULL instead should avoid that... Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Fixes: cd0ed03 ("arm64: use activity monitors for frequency invariance") Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Link: https://lore.kernel.org/r/01493d64-2bce-d968-86dc-11a122a9c07d@omp.ru Signed-off-by: Will Deacon <will@kernel.org>
1 parent 61d2d18 commit d4955c0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/arm64/kernel/topology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ static void amu_fie_setup(const struct cpumask *cpus)
237237
for_each_cpu(cpu, cpus) {
238238
if (!freq_counters_valid(cpu) ||
239239
freq_inv_set_max_ratio(cpu,
240-
cpufreq_get_hw_max_freq(cpu) * 1000,
240+
cpufreq_get_hw_max_freq(cpu) * 1000ULL,
241241
arch_timer_get_rate()))
242242
return;
243243
}

0 commit comments

Comments
 (0)