[BUGFIX][PATCH v5 2/9] perf config: Finally free a config set after collect_config() worked

From: Taeung Song
Date: Tue May 31 2016 - 13:27:19 EST


Current colllect_config() free a config set on failure.
But it is needed to finally free it at perf_config_set__new()
after collect_config() worked.

Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
Signed-off-by: Taeung Song <treeze.taeung@xxxxxxxxx>
---
tools/perf/util/config.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index b500737..d013f90 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -639,7 +639,6 @@ static int collect_config(const char *var, const char *value,

out_free:
free(key);
- perf_config_set__delete(set);
return -1;
}

@@ -649,7 +648,8 @@ 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);
}

return set;
--
2.5.0