Commit a0100a36 authored by Ian Rogers's avatar Ian Rogers Committed by Greg Kroah-Hartman

perf parse-events: Fix 3 use after frees found with clang ASAN

[ Upstream commit d4953f7e ]

Reproducible with a clang asan build and then running perf test in
particular 'Parse event definition strings'.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: clang-built-linux@googlegroups.com
Link: http://lore.kernel.org/lkml/20200314170356.62914-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 9d8b5dba
...@@ -1290,6 +1290,7 @@ void perf_evsel__exit(struct perf_evsel *evsel) ...@@ -1290,6 +1290,7 @@ void perf_evsel__exit(struct perf_evsel *evsel)
thread_map__put(evsel->threads); thread_map__put(evsel->threads);
zfree(&evsel->group_name); zfree(&evsel->group_name);
zfree(&evsel->name); zfree(&evsel->name);
zfree(&evsel->pmu_name);
perf_evsel__object.fini(evsel); perf_evsel__object.fini(evsel);
} }
......
...@@ -1261,7 +1261,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, ...@@ -1261,7 +1261,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,
attr.type = pmu->type; attr.type = pmu->type;
evsel = __add_event(list, &parse_state->idx, &attr, NULL, pmu, NULL, auto_merge_stats); evsel = __add_event(list, &parse_state->idx, &attr, NULL, pmu, NULL, auto_merge_stats);
if (evsel) { if (evsel) {
evsel->pmu_name = name; evsel->pmu_name = name ? strdup(name) : NULL;
evsel->use_uncore_alias = use_uncore_alias; evsel->use_uncore_alias = use_uncore_alias;
return 0; return 0;
} else { } else {
...@@ -1302,7 +1302,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, ...@@ -1302,7 +1302,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,
evsel->snapshot = info.snapshot; evsel->snapshot = info.snapshot;
evsel->metric_expr = info.metric_expr; evsel->metric_expr = info.metric_expr;
evsel->metric_name = info.metric_name; evsel->metric_name = info.metric_name;
evsel->pmu_name = name; evsel->pmu_name = name ? strdup(name) : NULL;
evsel->use_uncore_alias = use_uncore_alias; evsel->use_uncore_alias = use_uncore_alias;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment