aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2014-03-16 21:45:49 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-03-18 17:17:01 -0400
commit574799bfdbc3a13e0b5e2f6af34b761bde743a9a (patch)
treeba56c148f77f645414ff46f2d86d111415372874 /tools
parent11c9abf2270793bd1c1b8828edb4223f8010e56c (diff)
perf tools: Fix memory leak when synthesizing thread records
Checking default guest machine should be done before allocating event structures otherwise it'll leak memory. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Don Zickus <dzickus@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Joe Mario <jmario@redhat.com> Link: http://lkml.kernel.org/r/87ob15tx6a.fsf@sejong.aot.lge.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/event.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index ebb48a623407..9d12aa6dd485 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -446,6 +446,9 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
446 union perf_event *comm_event, *mmap_event, *fork_event; 446 union perf_event *comm_event, *mmap_event, *fork_event;
447 int err = -1; 447 int err = -1;
448 448
449 if (machine__is_default_guest(machine))
450 return 0;
451
449 comm_event = malloc(sizeof(comm_event->comm) + machine->id_hdr_size); 452 comm_event = malloc(sizeof(comm_event->comm) + machine->id_hdr_size);
450 if (comm_event == NULL) 453 if (comm_event == NULL)
451 goto out; 454 goto out;
@@ -458,9 +461,6 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
458 if (fork_event == NULL) 461 if (fork_event == NULL)
459 goto out_free_mmap; 462 goto out_free_mmap;
460 463
461 if (machine__is_default_guest(machine))
462 return 0;
463
464 snprintf(proc_path, sizeof(proc_path), "%s/proc", machine->root_dir); 464 snprintf(proc_path, sizeof(proc_path), "%s/proc", machine->root_dir);
465 proc = opendir(proc_path); 465 proc = opendir(proc_path);
466 466