diff options
author | Ian Rogers <irogers@google.com> | 2021-11-07 01:00:01 -0800 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2021-11-07 15:39:25 -0300 |
commit | 07eafd4e053a41d72611848b8758df0752b53ee4 (patch) | |
tree | 49140217f326f358935eaa4bcc6b15cd108139c3 /tools/perf/bench | |
parent | 6c1912898ed21bef2d7f8b52902b8bc3c0e5c2b5 (diff) | |
download | linux-stable-07eafd4e053a41d72611848b8758df0752b53ee4.tar.gz linux-stable-07eafd4e053a41d72611848b8758df0752b53ee4.tar.bz2 linux-stable-07eafd4e053a41d72611848b8758df0752b53ee4.zip |
perf parse-event: Add init and exit to parse_event_error
parse_events() may succeed but leave string memory allocations reachable
in the error.
Add an init/exit that must be called to initialize and clean up the
error. This fixes a leak in metricgroup parse_ids.
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: John Garry <john.garry@huawei.com>
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/20211107090002.3784612-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/bench')
-rw-r--r-- | tools/perf/bench/evlist-open-close.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/perf/bench/evlist-open-close.c b/tools/perf/bench/evlist-open-close.c index 3f9518936367..482738e9bdad 100644 --- a/tools/perf/bench/evlist-open-close.c +++ b/tools/perf/bench/evlist-open-close.c @@ -78,7 +78,7 @@ static int evlist__count_evsel_fds(struct evlist *evlist) static struct evlist *bench__create_evlist(char *evstr) { - struct parse_events_error err = { .idx = 0, }; + struct parse_events_error err; struct evlist *evlist = evlist__new(); int ret; @@ -87,14 +87,16 @@ static struct evlist *bench__create_evlist(char *evstr) return NULL; } + parse_events_error__init(&err); ret = parse_events(evlist, evstr, &err); if (ret) { parse_events_error__print(&err, evstr); + parse_events_error__exit(&err); pr_err("Run 'perf list' for a list of valid events\n"); ret = 1; goto out_delete_evlist; } - + parse_events_error__exit(&err); ret = evlist__create_maps(evlist, &opts.target); if (ret < 0) { pr_err("Not enough memory to create thread/cpu maps\n"); |