summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Shtylyov <s.shtylyov@omp.ru>2022-09-16 23:17:07 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-10-26 13:25:55 +0200
commit904f881b57360cf85de962d84d8614d94431f60e (patch)
tree2c9494d1336b4ec39d0c49717c6529fc99dfb6f9
parentb5dc2f25789dde48e518bfb9ded5cc12a0166fc0 (diff)
downloadlinux-904f881b57360cf85de962d84d8614d94431f60e.tar.gz
linux-904f881b57360cf85de962d84d8614d94431f60e.tar.bz2
linux-904f881b57360cf85de962d84d8614d94431f60e.zip
arm64: topology: fix possible overflow in amu_fie_setup()
commit d4955c0ad77dbc684fc716387070ac24801b8bca upstream. 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: cd0ed03a8903 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/arm64/kernel/topology.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
index 543c67cae02f..4358bc319306 100644
--- a/arch/arm64/kernel/topology.c
+++ b/arch/arm64/kernel/topology.c
@@ -158,7 +158,7 @@ static int validate_cpu_freq_invariance_counters(int cpu)
}
/* Convert maximum frequency from KHz to Hz and validate */
- max_freq_hz = cpufreq_get_hw_max_freq(cpu) * 1000;
+ max_freq_hz = cpufreq_get_hw_max_freq(cpu) * 1000ULL;
if (unlikely(!max_freq_hz)) {
pr_debug("CPU%d: invalid maximum frequency.\n", cpu);
return -EINVAL;