diff options
| author | Atish Patra <atishp@rivosinc.com> | 2024-12-12 16:09:33 -0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-01-17 13:40:45 +0100 |
| commit | 7ce916f4e975d71bc36807af5085fd2c3e8ae5a3 (patch) | |
| tree | 470a25c48b4020a3647aaa6d4f671d7e756747b2 /drivers/perf | |
| parent | 6191b1a474e17d8e945b9a60218bcb75f4c546e9 (diff) | |
| download | linux-7ce916f4e975d71bc36807af5085fd2c3e8ae5a3.tar.gz linux-7ce916f4e975d71bc36807af5085fd2c3e8ae5a3.tar.bz2 linux-7ce916f4e975d71bc36807af5085fd2c3e8ae5a3.zip | |
drivers/perf: riscv: Return error for default case
[ Upstream commit 2c206cdede567f53035c622e846678a996f39d69 ]
If the upper two bits has an invalid valid (0x1), the event mapping
is not reliable as it returns an uninitialized variable.
Return appropriate value for the default case.
Fixes: f0c9363db2dd ("perf/riscv-sbi: Add platform specific firmware event handling")
Signed-off-by: Atish Patra <atishp@rivosinc.com>
Link: https://lore.kernel.org/r/20241212-pmu_event_fixes_v2-v2-2-813e8a4f5962@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/perf')
| -rw-r--r-- | drivers/perf/riscv_pmu_sbi.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c index 3473ba02abf3..da3651d32906 100644 --- a/drivers/perf/riscv_pmu_sbi.c +++ b/drivers/perf/riscv_pmu_sbi.c @@ -507,7 +507,7 @@ static int pmu_sbi_event_map(struct perf_event *event, u64 *econfig) { u32 type = event->attr.type; u64 config = event->attr.config; - int ret; + int ret = -ENOENT; /* * Ensure we are finished checking standard hardware events for @@ -551,10 +551,11 @@ static int pmu_sbi_event_map(struct perf_event *event, u64 *econfig) ret = SBI_PMU_EVENT_TYPE_FW << 16 | RISCV_PLAT_FW_EVENT; *econfig = config & RISCV_PMU_PLAT_FW_EVENT_MASK; break; + default: + break; } break; default: - ret = -ENOENT; break; } |
