aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2010-03-17 17:21:01 -0400
committerIngo Molnar <mingo@elte.hu>2010-03-18 13:39:40 -0400
commit4b24a88b35e15e04bd8f2c5dda65b5dc8ebca05f (patch)
tree82d38330852a4761794875d431c39f522bae95c8
parentcb7d6b5053e86598735d9af19930f5929f007b7f (diff)
perf_events: Fix resource leak in x86 __hw_perf_event_init()
If reserve_pmc_hardware() succeeds but reserve_ds_buffers() fails, then we need to release_pmc_hardware. It won't be done by the destroy() callback because we return before setting it in case of error. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: <stable@kernel.org> Cc: peterz@infradead.org Cc: paulus@samba.org Cc: davem@davemloft.net Cc: fweisbec@gmail.com Cc: robert.richter@amd.com Cc: perfmon2-devel@lists.sf.net LKML-Reference: <4ba1568b.15185e0a.182a.7802@mx.google.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> -- arch/x86/kernel/cpu/perf_event.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
-rw-r--r--arch/x86/kernel/cpu/perf_event.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 14eca80918dc..f571f514de2a 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -455,8 +455,11 @@ static int __hw_perf_event_init(struct perf_event *event)
455 if (atomic_read(&active_events) == 0) { 455 if (atomic_read(&active_events) == 0) {
456 if (!reserve_pmc_hardware()) 456 if (!reserve_pmc_hardware())
457 err = -EBUSY; 457 err = -EBUSY;
458 else 458 else {
459 err = reserve_ds_buffers(); 459 err = reserve_ds_buffers();
460 if (err)
461 release_pmc_hardware();
462 }
460 } 463 }
461 if (!err) 464 if (!err)
462 atomic_inc(&active_events); 465 atomic_inc(&active_events);