diff options
author | Taeung Song <[email protected]> | 2016-06-07 18:26:11 +0900 |
---|---|---|
committer | Arnaldo Carvalho de Melo <[email protected]> | 2016-06-07 10:58:55 -0300 |
commit | 25d8f48f78f37dd6af08bd11212ab3d53a4c8cc6 (patch) | |
tree | 8a1a395f662939bc8f0079828d7e938623923777 | |
parent | c58c49ac630979a285d574b3f72a528209515fb3 (diff) |
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: Taeung Song <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Masami Hiramatsu <[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/config.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index c73f1c4d1ca9..e086f593a2aa 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -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; |