From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Ian Rogers <irogers@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>,
Kajol Jain <kjain@linux.ibm.com>, Andi Kleen <ak@linux.intel.com>,
Jin Yao <yao.jin@linux.intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Leo Yan <leo.yan@linaro.org>,
linux-kernel@vger.kernel.org,
Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH 2/2] perf parse-events: Avoid an uninitialized read.
Date: Wed, 26 Aug 2020 10:20:13 -0300 [thread overview]
Message-ID: <20200826132013.GG1059382@kernel.org> (raw)
In-Reply-To: <20200826113418.GC753783@krava>
Em Wed, Aug 26, 2020 at 01:34:18PM +0200, Jiri Olsa escreveu:
> On Tue, Aug 25, 2020 at 09:29:10PM -0700, Ian Rogers wrote:
> > 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: Ian Rogers <irogers@google.com>
>
> Acked-by: Jiri Olsa <jolsa@redhat.com>
Thanks, applied.
- Arnaldo
> thanks,
> jirka
>
> > ---
> > tools/perf/util/parse-events.c | 30 +++++++++++++++++-------------
> > 1 file changed, 17 insertions(+), 13 deletions(-)
> >
> > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> > index 9f7260e69113..3d7a48b488ed 100644
> > --- a/tools/perf/util/parse-events.c
> > +++ b/tools/perf/util/parse-events.c
> > @@ -1533,19 +1533,23 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,
> > evsel = __add_event(list, &parse_state->idx, &attr, true,
> > get_config_name(head_config), pmu,
> > &config_terms, auto_merge_stats, NULL);
> > - if (evsel) {
> > - evsel->unit = info.unit;
> > - evsel->scale = info.scale;
> > - evsel->per_pkg = info.per_pkg;
> > - evsel->snapshot = info.snapshot;
> > - evsel->metric_expr = info.metric_expr;
> > - evsel->metric_name = info.metric_name;
> > - evsel->pmu_name = name ? strdup(name) : NULL;
> > - evsel->use_uncore_alias = use_uncore_alias;
> > - evsel->percore = config_term_percore(&evsel->config_terms);
> > - }
> > -
> > - return evsel ? 0 : -ENOMEM;
> > + if (!evsel)
> > + return -ENOMEM;
> > +
> > + evsel->pmu_name = name ? strdup(name) : NULL;
> > + evsel->use_uncore_alias = use_uncore_alias;
> > + evsel->percore = config_term_percore(&evsel->config_terms);
> > +
> > + if (parse_state->fake_pmu)
> > + return 0;
> > +
> > + evsel->unit = info.unit;
> > + evsel->scale = info.scale;
> > + 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,
> > --
> > 2.28.0.297.g1956fa8f8d-goog
> >
>
--
- Arnaldo
next prev parent reply other threads:[~2020-08-26 13:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-26 4:29 [PATCH 1/2] perf expr: Force encapsulation on expr_id_data Ian Rogers
2020-08-26 4:29 ` [PATCH 2/2] perf parse-events: Avoid an uninitialized read Ian Rogers
2020-08-26 11:34 ` Jiri Olsa
2020-08-26 13:20 ` Arnaldo Carvalho de Melo [this message]
2020-08-26 11:33 ` [PATCH 1/2] perf expr: Force encapsulation on expr_id_data Jiri Olsa
2020-08-26 15:32 ` Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200826132013.GG1059382@kernel.org \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=kan.liang@linux.intel.com \
--cc=kjain@linux.ibm.com \
--cc=leo.yan@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=yao.jin@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox