All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Robert Richter <robert.richter@amd.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
	robert.richter@amd.com, will.deacon@arm.com, tglx@linutronix.de,
	mingo@elte.hu
Subject: [tip:perf/urgent] oprofile, ARM: Release resources on failure
Date: Mon, 4 Oct 2010 20:24:39 GMT	[thread overview]
Message-ID: <tip-98d943b02f6f1b57787ff1aa6f34d019a407e3ee@git.kernel.org> (raw)
In-Reply-To: <20100929145225.GJ13563@erda.amd.com>

Commit-ID:  98d943b02f6f1b57787ff1aa6f34d019a407e3ee
Gitweb:     http://git.kernel.org/tip/98d943b02f6f1b57787ff1aa6f34d019a407e3ee
Author:     Robert Richter <robert.richter@amd.com>
AuthorDate: Wed, 29 Sep 2010 16:52:25 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 30 Sep 2010 09:14:25 +0200

oprofile, ARM: Release resources on failure

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

Signed-off-by: Robert Richter <robert.richter@amd.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: <stable@kernel.org> # .35.x
LKML-Reference: <20100929145225.GJ13563@erda.amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 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)

  parent reply	other threads:[~2010-10-04 20:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-29 14:52 [PATCH] oprofile, arm: proper release resources on failure Robert Richter
2010-09-29 14:52 ` Robert Richter
2010-09-29 15:39 ` Will Deacon
2010-09-29 15:39   ` Will Deacon
2010-09-29 16:50   ` Robert Richter
2010-09-29 16:50     ` Robert Richter
2010-09-29 16:59     ` Robert Richter
2010-09-29 16:59       ` Robert Richter
2010-09-29 17:32       ` Will Deacon
2010-09-29 17:32         ` Will Deacon
2010-09-29 17:39         ` Robert Richter
2010-09-29 17:39           ` Robert Richter
2010-10-04 20:24 ` tip-bot for Robert Richter [this message]
2010-10-16 16:32 ` [tip:perf/core] oprofile, ARM: Release " tip-bot for Robert Richter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-98d943b02f6f1b57787ff1aa6f34d019a407e3ee@git.kernel.org \
    --to=robert.richter@amd.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.