lkml.org 
[lkml]   [2019]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v4 4/9] perf tools: splice events onto evlist even on error
Em Mon, Oct 28, 2019 at 10:07:12PM +0100, Jiri Olsa escreveu:
> On Fri, Oct 25, 2019 at 11:08:22AM -0700, Ian Rogers wrote:
> > If event parsing fails the event list is leaked, instead splice the list
> > onto the out result and let the caller cleanup.
> >
> > An example input for parse_events found by libFuzzer that reproduces
> > this memory leak is 'm{'.
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
>
> Acked-by: Jiri Olsa <jolsa@kernel.org>

Thanks, applied.

> thanks,
> jirka
>
> > ---
> > tools/perf/util/parse-events.c | 17 +++++++++++------
> > 1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> > index c516d0cce946..4c4c6f3e866a 100644
> > --- a/tools/perf/util/parse-events.c
> > +++ b/tools/perf/util/parse-events.c
> > @@ -1952,15 +1952,20 @@ int parse_events(struct evlist *evlist, const char *str,
> >
> > ret = parse_events__scanner(str, &parse_state, PE_START_EVENTS);
> > perf_pmu__parse_cleanup();
> > +
> > + if (!ret && list_empty(&parse_state.list)) {
> > + WARN_ONCE(true, "WARNING: event parser found nothing\n");
> > + return -1;
> > + }
> > +
> > + /*
> > + * Add list to the evlist even with errors to allow callers to clean up.
> > + */
> > + perf_evlist__splice_list_tail(evlist, &parse_state.list);
> > +
> > if (!ret) {
> > struct evsel *last;
> >
> > - if (list_empty(&parse_state.list)) {
> > - WARN_ONCE(true, "WARNING: event parser found nothing\n");
> > - return -1;
> > - }
> > -
> > - perf_evlist__splice_list_tail(evlist, &parse_state.list);
> > evlist->nr_groups += parse_state.nr_groups;
> > last = evlist__last(evlist);
> > last->cmdline_group_boundary = true;
> > --
> > 2.24.0.rc0.303.g954a862665-goog
> >

--

- Arnaldo

\
 
 \ /
  Last update: 2019-10-30 12:56    [W:0.190 / U:0.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site