Skip to content

Commit

Permalink
perf tools: Fix memory leak when synthesizing thread records
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
namhyung authored and acmel committed Mar 18, 2014
1 parent 11c9abf commit 574799b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/perf/util/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
union perf_event *comm_event, *mmap_event, *fork_event;
int err = -1;

if (machine__is_default_guest(machine))
return 0;

comm_event = malloc(sizeof(comm_event->comm) + machine->id_hdr_size);
if (comm_event == NULL)
goto out;
Expand All @@ -458,9 +461,6 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
if (fork_event == NULL)
goto out_free_mmap;

if (machine__is_default_guest(machine))
return 0;

snprintf(proc_path, sizeof(proc_path), "%s/proc", machine->root_dir);
proc = opendir(proc_path);

Expand Down

0 comments on commit 574799b

Please sign in to comment.