All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Namhyung Kim <namhyung.kim@lge.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, paulus@samba.org, hpa@zytor.com,
	mingo@redhat.com, a.p.zijlstra@chello.nl,
	acme@ghostprotocols.net, namhyung.kim@lge.com,
	fweisbec@gmail.com, tglx@linutronix.de, mingo@elte.hu
Subject: [tip:perf/urgent] perf/hwbp: Fix a possible memory leak
Date: Tue, 28 Feb 2012 01:13:42 -0800	[thread overview]
Message-ID: <tip-30ce2f7eef095d1b8d070740f1948629814fe3c7@git.kernel.org> (raw)
In-Reply-To: <1330391978-28070-1-git-send-email-namhyung.kim@lge.com>

Commit-ID:  30ce2f7eef095d1b8d070740f1948629814fe3c7
Gitweb:     http://git.kernel.org/tip/30ce2f7eef095d1b8d070740f1948629814fe3c7
Author:     Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Tue, 28 Feb 2012 10:19:38 +0900
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 28 Feb 2012 09:52:54 +0100

perf/hwbp: Fix a possible memory leak

If kzalloc() for TYPE_DATA failed on a given cpu, previous chunk
of TYPE_INST will be leaked. Fix it.

Thanks to Peter Zijlstra for suggesting this better solution. It
should work as long as the initial value of the region is all
0's and that's the case of static (per-cpu) memory allocation.

Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Link: http://lkml.kernel.org/r/1330391978-28070-1-git-send-email-namhyung.kim@lge.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/events/hw_breakpoint.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index b7971d6..ee706ce 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -651,10 +651,10 @@ int __init init_hw_breakpoint(void)
 
  err_alloc:
 	for_each_possible_cpu(err_cpu) {
-		if (err_cpu == cpu)
-			break;
 		for (i = 0; i < TYPE_MAX; i++)
 			kfree(per_cpu(nr_task_bp_pinned[i], cpu));
+		if (err_cpu == cpu)
+			break;
 	}
 
 	return -ENOMEM;

  reply	other threads:[~2012-02-28  9:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-27  3:02 [PATCH] hw breakpoint: Fix possible memory leak Namhyung Kim
2012-02-27 10:33 ` Peter Zijlstra
2012-02-27 10:44   ` Ingo Molnar
2012-02-27 11:04     ` Peter Zijlstra
2012-02-27 11:56       ` Ingo Molnar
2012-02-27 13:32         ` Namhyung Kim
2012-02-27 19:40           ` Ingo Molnar
2012-02-27 23:38             ` Frederic Weisbecker
2012-02-28  1:19               ` [PATCH v2] hw breakpoint: Fix a " Namhyung Kim
2012-02-28  9:13                 ` tip-bot for Namhyung Kim [this message]
2012-02-27 12:45       ` [PATCH] hw breakpoint: Fix " Namhyung Kim
2012-02-27 12:46         ` Peter Zijlstra
2012-02-27 12:50           ` Namhyung Kim

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-30ce2f7eef095d1b8d070740f1948629814fe3c7@git.kernel.org \
    --to=namhyung.kim@lge.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=fweisbec@gmail.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=paulus@samba.org \
    --cc=tglx@linutronix.de \
    /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.