Skip to content

Commit

Permalink
perf: Fix perf_init_event()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Sep 10, 2010
1 parent cee010e commit e5f4d33
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -5236,12 +5236,15 @@ struct pmu *perf_init_event(struct perf_event *event)
list_for_each_entry_rcu(pmu, &pmus, entry) {
int ret = pmu->event_init(event);
if (!ret)
break;
goto unlock;

if (ret != -ENOENT) {
pmu = ERR_PTR(ret);
break;
goto unlock;
}
}
pmu = ERR_PTR(-ENOENT);
unlock:
srcu_read_unlock(&pmus_srcu, idx);

return pmu;
Expand Down

0 comments on commit e5f4d33

Please sign in to comment.