Skip to contentSkip to conversation

perf config: If collect_config() is failed, finally free a config set after it is done

PATCH RESEND Superseded Taeung Song 1 participant 1 message Jun 6, 2016 perf events

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v6 1/1 perf config: If collect_config() is failed, finally free a config set after it is done

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().

Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Alexander Shishkin <[email protected]>
---
 tools/perf/util/config.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/config.c +4 -2
index c73f1c4..cb749d3 100644
@@ -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);
+			return NULL;
+		}
 	}
 
 	return set;
Signature · 1 line
2.5.0