linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] oprofile, arm: proper release resources on failure
@ 2010-09-29 14:03 Robert Richter
  0 siblings, 0 replies; 7+ messages in thread
From: Robert Richter @ 2010-09-29 14:03 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes a resource leak on failure, where the oprofilefs and
some counters may not released properly.

Fix is also for 2.6.35-stable.

Cc: Will Deacon <will.deacon@arm.com>
Cc: stable at kernel.org
Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 arch/arm/oprofile/common.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/oprofile/common.c b/arch/arm/oprofile/common.c
index 0691176..72e09eb 100644
--- a/arch/arm/oprofile/common.c
+++ b/arch/arm/oprofile/common.c
@@ -102,6 +102,7 @@ static int op_create_counter(int cpu, int event)
 	if (IS_ERR(pevent)) {
 		ret = PTR_ERR(pevent);
 	} else if (pevent->state != PERF_EVENT_STATE_ACTIVE) {
+		perf_event_release_kernel(pevent);
 		pr_warning("oprofile: failed to enable event %d "
 				"on CPU %d\n", event, cpu);
 		ret = -EBUSY;
@@ -365,6 +366,7 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
 	ret = init_driverfs();
 	if (ret) {
 		kfree(counter_config);
+		counter_config = NULL;
 		return ret;
 	}
 
@@ -402,7 +404,6 @@ void oprofile_arch_exit(void)
 	struct perf_event *event;
 
 	if (*perf_events) {
-		exit_driverfs();
 		for_each_possible_cpu(cpu) {
 			for (id = 0; id < perf_num_counters; ++id) {
 				event = perf_events[cpu][id];
@@ -413,8 +414,10 @@ void oprofile_arch_exit(void)
 		}
 	}
 
-	if (counter_config)
+	if (counter_config) {
 		kfree(counter_config);
+		exit_driverfs();
+	}
 }
 #else
 int __init oprofile_arch_init(struct oprofile_operations *ops)
-- 
1.7.2.2



-- 
Advanced Micro Devices, Inc.
Operating System Research Center

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] oprofile, arm: proper release resources on failure
@ 2010-09-29 14:52 Robert Richter
  2010-09-29 15:39 ` Will Deacon
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Richter @ 2010-09-29 14:52 UTC (permalink / raw)
  To: linux-arm-kernel

Will,

the patch below fixes a resource leak I found during code review. Can
you please review and test it (I don't have an ARM environment for
this available). If you are fine with the change, please ack. I want
to send it upstream via tip/perf/urgent.

Though you reworked the code already, parts of the fix are still valid
for latest oprofile code in oprofile/core.

Ingo,

if Will agrees with it, please apply it directly to tip/perf/urgent.

Thanks,

-Robert

--

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

end of thread, other threads:[~2010-09-29 17:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-29 14:03 [PATCH] oprofile, arm: proper release resources on failure Robert Richter
  -- strict thread matches above, loose matches on Subject: below --
2010-09-29 14:52 Robert Richter
2010-09-29 15:39 ` Will Deacon
2010-09-29 16:50   ` Robert Richter
2010-09-29 16:59     ` Robert Richter
2010-09-29 17:32       ` Will Deacon
2010-09-29 17:39         ` Robert Richter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).