提交 25d8f48f 编写于 作者: T Taeung Song 提交者: Arnaldo Carvalho de Melo

perf config: Constructor should free its allocated memory when failing

Because of die() at perf_parse_file() a config set was freed in
collect_config(), if failed.  But it is natural to free a config set
after collect_config() is done when some problems happened.

So, in case of failure, lastly free a config set at perf_config_set__new()
instead of freeing the config set in collect_config().
Signed-off-by: NTaeung Song <treeze.taeung@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1465291577-20973-2-git-send-email-treeze.taeung@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 c58c49ac
......@@ -643,7 +643,6 @@ static int collect_config(const char *var, const char *value,
out_free:
free(key);
perf_config_set__delete(set);
return -1;
}
......@@ -653,7 +652,10 @@ struct perf_config_set *perf_config_set__new(void)
if (set) {
INIT_LIST_HEAD(&set->sections);
perf_config(collect_config, set);
if (perf_config(collect_config, set) < 0) {
perf_config_set__delete(set);
set = NULL;
}
}
return set;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册