Commit 33321a06 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf parse-events: Avoid an uninitialized read when using fake PMUs

With a fake_pmu the pmu_info isn't populated by perf_pmu__check_alias.
In this case, don't try to copy the uninitialized values to the evsel.
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: Jin Yao <yao.jin@linux.intel.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@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>
Link: http://lore.kernel.org/lkml/20200826042910.1902374-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 313146a8
...@@ -1534,19 +1534,23 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, ...@@ -1534,19 +1534,23 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,
evsel = __add_event(list, &parse_state->idx, &attr, true, evsel = __add_event(list, &parse_state->idx, &attr, true,
get_config_name(head_config), pmu, get_config_name(head_config), pmu,
&config_terms, auto_merge_stats, NULL); &config_terms, auto_merge_stats, NULL);
if (evsel) { if (!evsel)
evsel->unit = info.unit; return -ENOMEM;
evsel->scale = info.scale;
evsel->per_pkg = info.per_pkg; evsel->pmu_name = name ? strdup(name) : NULL;
evsel->snapshot = info.snapshot; evsel->use_uncore_alias = use_uncore_alias;
evsel->metric_expr = info.metric_expr; evsel->percore = config_term_percore(&evsel->config_terms);
evsel->metric_name = info.metric_name;
evsel->pmu_name = name ? strdup(name) : NULL; if (parse_state->fake_pmu)
evsel->use_uncore_alias = use_uncore_alias; return 0;
evsel->percore = config_term_percore(&evsel->config_terms);
} evsel->unit = info.unit;
evsel->scale = info.scale;
return evsel ? 0 : -ENOMEM; evsel->per_pkg = info.per_pkg;
evsel->snapshot = info.snapshot;
evsel->metric_expr = info.metric_expr;
evsel->metric_name = info.metric_name;
return 0;
} }
int parse_events_multi_pmu_add(struct parse_events_state *parse_state, int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
......
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