Skip to content

Commit 940c5b2

Browse files
Lin MingIngo Molnar
authored andcommitted
perf: Fix the missing event initialization when pmu is found in idr
Currently, the event is not initialized if pmu is found in idr. This never causes bug just because now no pmu is associated with the idr id. Signed-off-by: Lin Ming <ming.m.lin@intel.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <1298812411.2699.9.camel@localhost> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 888a8a3 commit 940c5b2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

kernel/perf_event.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6098,17 +6098,22 @@ struct pmu *perf_init_event(struct perf_event *event)
60986098
{
60996099
struct pmu *pmu = NULL;
61006100
int idx;
6101+
int ret;
61016102

61026103
idx = srcu_read_lock(&pmus_srcu);
61036104

61046105
rcu_read_lock();
61056106
pmu = idr_find(&pmu_idr, event->attr.type);
61066107
rcu_read_unlock();
6107-
if (pmu)
6108+
if (pmu) {
6109+
ret = pmu->event_init(event);
6110+
if (ret)
6111+
pmu = ERR_PTR(ret);
61086112
goto unlock;
6113+
}
61096114

61106115
list_for_each_entry_rcu(pmu, &pmus, entry) {
6111-
int ret = pmu->event_init(event);
6116+
ret = pmu->event_init(event);
61126117
if (!ret)
61136118
goto unlock;
61146119

0 commit comments

Comments
 (0)