All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw breakpoint: Fix possible memory leak
@ 2012-02-27  3:02 Namhyung Kim
  2012-02-27 10:33 ` Peter Zijlstra
  0 siblings, 1 reply; 13+ messages in thread
From: Namhyung Kim @ 2012-02-27  3:02 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Namhyung Kim, Peter Zijlstra, Paul Mackerras,
	Arnaldo Carvalho de Melo, LKML

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

Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
---
 kernel/events/hw_breakpoint.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index b0309f76d777..58298b0d0e92 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -645,8 +645,12 @@ int __init init_hw_breakpoint(void)
 			task_bp_pinned = &per_cpu(nr_task_bp_pinned[i], cpu);
 			*task_bp_pinned = kzalloc(sizeof(int) * nr_slots[i],
 						  GFP_KERNEL);
-			if (!*task_bp_pinned)
+			if (!*task_bp_pinned) {
+				while (--i >= 0)
+					kfree(per_cpu(nr_task_bp_pinned[i],
+						      cpu));
 				goto err_alloc;
+			}
 		}
 	}
 
-- 
1.7.9


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

end of thread, other threads:[~2012-02-28  9:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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:perf/urgent] perf/hwbp: " tip-bot for Namhyung Kim
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

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.