From 418029b7324f8b90ac1dfbc8a44555d6905be761 Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Wed, 16 Jul 2014 10:19:44 +0300 Subject: [PATCH] perf machine: Fix leak of 'struct thread' on error path __machine__findnew_thread() creates a 'struct thread' but does not free it on the error path. Fix it. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1405495184-20441-3-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 5484fa4385fc..93c8b6fbc799 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -370,8 +370,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; -- 2.39.5