mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-11-23 03:04:21 +00:00
Previously, in sbi_pmu_ctr_cfg_match() function, ctr_idx was used immediately after pmu_ctr_find_fw() or pmu_ctr_find_hw() calls. In first case, array index was (ctr_idx - num_hw_ctrs), in second - ctr_idx. But pmu_ctr_find_fw() and pmu_ctr_find_hw() functions can return negative value, in which case writing in arrays with such indexes would corrupt sbi_pmu_hart_state structure. To avoid this situation, direct ctr_idx value check added. Signed-off-by: Alexander Chuprunov <alexander.chuprunov@syntacore.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20250918090706.2217603-4-alexander.chuprunov@syntacore.com Signed-off-by: Anup Patel <anup@brainfault.org>
33 KiB
33 KiB