lkml.org 
[lkml]   [2014]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 12/41] perf tools: Fix leak of 'struct thread' on error path
Date
__machine__findnew_thread() creates a 'struct thread'
but does not free it on the error path.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/machine.c | 4 +++-
tools/perf/util/thread.c | 6 ++++--
2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index c1c5ca3..18eaf31 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -349,8 +349,10 @@ static struct thread *__machine__findnew_thread(struct machine *machine,
* within thread__init_map_groups to find the thread
* leader and that would screwed the rb tree.
*/
- if (thread__init_map_groups(th, machine))
+ if (thread__init_map_groups(th, machine)) {
+ thread__delete(th);
return NULL;
+ }
}

return th;
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 149e417..b9a3ee4 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -95,8 +95,10 @@ void thread__delete(struct thread *thread)
{
struct comm *comm, *tmp;

- map_groups__put(thread->mg);
- thread->mg = NULL;
+ if (thread->mg) {
+ map_groups__put(thread->mg);
+ thread->mg = NULL;
+ }
list_for_each_entry_safe(comm, tmp, &thread->comm_list, list) {
list_del(&comm->list);
comm__free(comm);
--
1.8.3.2


\
 
 \ /
  Last update: 2014-07-14 20:21    [W:0.472 / U:0.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site