diff options
author | Sergey Shtylyov <s.shtylyov@omp.ru> | 2022-09-16 23:17:07 +0300 |
---|---|---|
committer | Will Deacon <will@kernel.org> | 2022-09-22 12:57:06 +0100 |
commit | d4955c0ad77dbc684fc716387070ac24801b8bca (patch) | |
tree | 9311ec80e3e76ab5f92e1ce2f8c1f5da9398f1bc /arch | |
parent | 61d2d1808b20da4a45a90b4bd61ae92f729bab78 (diff) | |
download | lwn-d4955c0ad77dbc684fc716387070ac24801b8bca.tar.gz lwn-d4955c0ad77dbc684fc716387070ac24801b8bca.zip |
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: 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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm64/kernel/topology.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index ad2bfc794257..44ebf5b2fc4b 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -237,7 +237,7 @@ static void amu_fie_setup(const struct cpumask *cpus) for_each_cpu(cpu, cpus) { if (!freq_counters_valid(cpu) || freq_inv_set_max_ratio(cpu, - cpufreq_get_hw_max_freq(cpu) * 1000, + cpufreq_get_hw_max_freq(cpu) * 1000ULL, arch_timer_get_rate())) return; } |