Commit e5f4d339 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

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: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent cee010ec
...@@ -5236,12 +5236,15 @@ struct pmu *perf_init_event(struct perf_event *event) ...@@ -5236,12 +5236,15 @@ struct pmu *perf_init_event(struct perf_event *event)
list_for_each_entry_rcu(pmu, &pmus, entry) { list_for_each_entry_rcu(pmu, &pmus, entry) {
int ret = pmu->event_init(event); int ret = pmu->event_init(event);
if (!ret) if (!ret)
break; goto unlock;
if (ret != -ENOENT) { if (ret != -ENOENT) {
pmu = ERR_PTR(ret); pmu = ERR_PTR(ret);
break; goto unlock;
} }
} }
pmu = ERR_PTR(-ENOENT);
unlock:
srcu_read_unlock(&pmus_srcu, idx); srcu_read_unlock(&pmus_srcu, idx);
return pmu; return pmu;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment