diff options
author | Jiri Olsa <[email protected]> | 2018-02-15 13:26:29 +0100 |
---|---|---|
committer | Arnaldo Carvalho de Melo <[email protected]> | 2018-02-16 14:25:56 -0300 |
commit | 81f981d7ec43ed93901c12b6521d39b06f1ed3d3 (patch) | |
tree | 82eb4797d8dcd323dc626bde756b0153ce37ace2 | |
parent | c39629614640a7a5331bf156b0d26effade0a67f (diff) |
perf machine: Free root_dir in machine__init() error path
Free root_dir in machine__init() error path.
Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r-- | tools/perf/util/machine.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index b05a67464c03..c976384f9022 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -50,6 +50,8 @@ static void machine__threads_init(struct machine *machine) int machine__init(struct machine *machine, const char *root_dir, pid_t pid) { + int err = -ENOMEM; + memset(machine, 0, sizeof(*machine)); map_groups__init(&machine->kmaps, machine); RB_CLEAR_NODE(&machine->rb_node); @@ -79,7 +81,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid) char comm[64]; if (thread == NULL) - return -ENOMEM; + goto out; snprintf(comm, sizeof(comm), "[guest/%d]", pid); thread__set_comm(thread, comm, 0); @@ -87,7 +89,11 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid) } machine->current_tid = NULL; + err = 0; +out: + if (err) + zfree(&machine->root_dir); return 0; } |