public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* perf: fix the missing event initialization when pmu is found in idr
@ 2011-02-27 13:13 Lin Ming
  2011-02-28  9:18 ` Peter Zijlstra
  2011-03-04 11:50 ` [tip:perf/core] perf: Fix " tip-bot for Lin Ming
  0 siblings, 2 replies; 3+ messages in thread
From: Lin Ming @ 2011-02-27 13:13 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar; +Cc: linux-kernel

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.
This patch fixes the potential bug.

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
---
 kernel/perf_event.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 64a018e..821ce82 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -6098,17 +6098,22 @@ struct pmu *perf_init_event(struct perf_event *event)
 {
 	struct pmu *pmu = NULL;
 	int idx;
+	int ret;
 
 	idx = srcu_read_lock(&pmus_srcu);
 
 	rcu_read_lock();
 	pmu = idr_find(&pmu_idr, event->attr.type);
 	rcu_read_unlock();
-	if (pmu)
+	if (pmu) {
+		ret = pmu->event_init(event);
+		if (ret)
+			pmu = ERR_PTR(ret);
 		goto unlock;
+	}
 
 	list_for_each_entry_rcu(pmu, &pmus, entry) {
-		int ret = pmu->event_init(event);
+		ret = pmu->event_init(event);
 		if (!ret)
 			goto unlock;
 



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: perf: fix the missing event initialization when pmu is found in idr
  2011-02-27 13:13 perf: fix the missing event initialization when pmu is found in idr Lin Ming
@ 2011-02-28  9:18 ` Peter Zijlstra
  2011-03-04 11:50 ` [tip:perf/core] perf: Fix " tip-bot for Lin Ming
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2011-02-28  9:18 UTC (permalink / raw)
  To: Lin Ming; +Cc: Ingo Molnar, linux-kernel

On Sun, 2011-02-27 at 21:13 +0800, Lin Ming wrote:
> 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. 

Yeah, d'0h, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:perf/core] perf: Fix the missing event initialization when pmu is found in idr
  2011-02-27 13:13 perf: fix the missing event initialization when pmu is found in idr Lin Ming
  2011-02-28  9:18 ` Peter Zijlstra
@ 2011-03-04 11:50 ` tip-bot for Lin Ming
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Lin Ming @ 2011-03-04 11:50 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, a.p.zijlstra, ming.m.lin, tglx, mingo

Commit-ID:  940c5b2971de443df22eed0441bc74fb0116e9f5
Gitweb:     http://git.kernel.org/tip/940c5b2971de443df22eed0441bc74fb0116e9f5
Author:     Lin Ming <ming.m.lin@intel.com>
AuthorDate: Sun, 27 Feb 2011 21:13:31 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 4 Mar 2011 11:32:50 +0100

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>
---
 kernel/perf_event.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 64a018e..821ce82 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -6098,17 +6098,22 @@ struct pmu *perf_init_event(struct perf_event *event)
 {
 	struct pmu *pmu = NULL;
 	int idx;
+	int ret;
 
 	idx = srcu_read_lock(&pmus_srcu);
 
 	rcu_read_lock();
 	pmu = idr_find(&pmu_idr, event->attr.type);
 	rcu_read_unlock();
-	if (pmu)
+	if (pmu) {
+		ret = pmu->event_init(event);
+		if (ret)
+			pmu = ERR_PTR(ret);
 		goto unlock;
+	}
 
 	list_for_each_entry_rcu(pmu, &pmus, entry) {
-		int ret = pmu->event_init(event);
+		ret = pmu->event_init(event);
 		if (!ret)
 			goto unlock;
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-04 11:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-27 13:13 perf: fix the missing event initialization when pmu is found in idr Lin Ming
2011-02-28  9:18 ` Peter Zijlstra
2011-03-04 11:50 ` [tip:perf/core] perf: Fix " tip-bot for Lin Ming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox