Commit e5f4d3394a52ac351f1a479fe136d92fa5228eff
Committed by
Ingo Molnar
1 parent
cee010ec52
perf: Fix perf_init_event()
We ought to return -ENOENT when non of the registered PMUs recognise the requested event. This fixes a boot crash that occurs if no PMU is available but the NMI watchdog tries to register an event. Reported-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Showing 1 changed file with 5 additions and 2 deletions Side-by-side Diff
kernel/perf_event.c
... | ... | @@ -5236,12 +5236,15 @@ |
5236 | 5236 | list_for_each_entry_rcu(pmu, &pmus, entry) { |
5237 | 5237 | int ret = pmu->event_init(event); |
5238 | 5238 | if (!ret) |
5239 | - break; | |
5239 | + goto unlock; | |
5240 | + | |
5240 | 5241 | if (ret != -ENOENT) { |
5241 | 5242 | pmu = ERR_PTR(ret); |
5242 | - break; | |
5243 | + goto unlock; | |
5243 | 5244 | } |
5244 | 5245 | } |
5246 | + pmu = ERR_PTR(-ENOENT); | |
5247 | +unlock: | |
5245 | 5248 | srcu_read_unlock(&pmus_srcu, idx); |
5246 | 5249 | |
5247 | 5250 | return pmu; |