lkml.org 
[lkml]   [2012]   [Feb]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] hw breakpoint: Fix possible memory leak
Date
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


\
 
 \ /
  Last update: 2012-02-27 03:45    [W:0.164 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site