[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-81f981d7ec43ed93901c12b6521d39b06f1ed3d3@git.kernel.org>
Date: Sat, 17 Feb 2018 03:25:27 -0800
From: tip-bot for Jiri Olsa <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: alexander.shishkin@...ux.intel.com, mingo@...nel.org,
jolsa@...nel.org, namhyung@...nel.org, dsahern@...il.com,
hpa@...or.com, linux-kernel@...r.kernel.org, peterz@...radead.org,
acme@...hat.com, tglx@...utronix.de
Subject: [tip:perf/core] perf machine: Free root_dir in machine__init()
error path
Commit-ID: 81f981d7ec43ed93901c12b6521d39b06f1ed3d3
Gitweb: https://git.kernel.org/tip/81f981d7ec43ed93901c12b6521d39b06f1ed3d3
Author: Jiri Olsa <jolsa@...nel.org>
AuthorDate: Thu, 15 Feb 2018 13:26:29 +0100
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Fri, 16 Feb 2018 14:25:56 -0300
perf machine: Free root_dir in machine__init() error path
Free root_dir in machine__init() error path.
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: David Ahern <dsahern@...il.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Link: http://lkml.kernel.org/r/20180215122635.24029-4-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/machine.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index b05a674..c976384 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;
}
Powered by blists - more mailing lists