Commit 574799bf authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

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: default avatarNamhyung 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 11c9abf2
...@@ -446,6 +446,9 @@ int perf_event__synthesize_threads(struct perf_tool *tool, ...@@ -446,6 +446,9 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
union perf_event *comm_event, *mmap_event, *fork_event; union perf_event *comm_event, *mmap_event, *fork_event;
int err = -1; int err = -1;
if (machine__is_default_guest(machine))
return 0;
comm_event = malloc(sizeof(comm_event->comm) + machine->id_hdr_size); comm_event = malloc(sizeof(comm_event->comm) + machine->id_hdr_size);
if (comm_event == NULL) if (comm_event == NULL)
goto out; goto out;
...@@ -458,9 +461,6 @@ int perf_event__synthesize_threads(struct perf_tool *tool, ...@@ -458,9 +461,6 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
if (fork_event == NULL) if (fork_event == NULL)
goto out_free_mmap; goto out_free_mmap;
if (machine__is_default_guest(machine))
return 0;
snprintf(proc_path, sizeof(proc_path), "%s/proc", machine->root_dir); snprintf(proc_path, sizeof(proc_path), "%s/proc", machine->root_dir);
proc = opendir(proc_path); proc = opendir(proc_path);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment