Skip to content

Commit 2c206cd

Browse files
atishp04palmer-dabbelt
authored andcommitted
drivers/perf: riscv: Return error for default case
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: f0c9363 ("perf/riscv-sbi: Add platform specific firmware event handling") Signed-off-by: Atish Patra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent fc58db9 commit 2c206cd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/perf/riscv_pmu_sbi.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ static int pmu_sbi_event_map(struct perf_event *event, u64 *econfig)
507507
{
508508
u32 type = event->attr.type;
509509
u64 config = event->attr.config;
510-
int ret;
510+
int ret = -ENOENT;
511511

512512
/*
513513
* 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)
551551
ret = SBI_PMU_EVENT_TYPE_FW << 16 | RISCV_PLAT_FW_EVENT;
552552
*econfig = config & RISCV_PMU_PLAT_FW_EVENT_MASK;
553553
break;
554+
default:
555+
break;
554556
}
555557
break;
556558
default:
557-
ret = -ENOENT;
558559
break;
559560
}
560561

0 commit comments

Comments
 (0)