[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200513133627.GC5583@kernel.org>
Date: Wed, 13 May 2020 10:36:27 -0300
From: Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
To: Ian Rogers <irogers@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Andi Kleen <ak@...ux.intel.com>, linux-kernel@...r.kernel.org,
Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH] perf evsel: Fix 2 memory leaks
Em Tue, May 12, 2020 at 04:59:18PM -0700, Ian Rogers escreveu:
> If allocated, perf_pkg_mask and metric_events need freeing.
Applied, were those found with some tool? Or just by visual inspection?
Also I noticed that evsel->metric_events is correctly initialized to
NULL in evsel__init(), but evsel->per_pkg_mask isn't, and while
evsel__new() uses zalloc() it is possible, IIRC, for evsels associated
with hists to be part of a larger struct, so I think the safest way is
to initialize evsel->per_pkg_mask to NULL in evsel__init(), will do it
in a follow up patch.
- Arnaldo
> Reviewed-by: Andi Kleen <ak@...ux.intel.com>
> Signed-off-by: Ian Rogers <irogers@...gle.com>
> ---
> tools/perf/util/evsel.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index a2397ca4d57a..654b79c1f4ac 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -1266,6 +1266,8 @@ void evsel__exit(struct evsel *evsel)
> zfree(&evsel->group_name);
> zfree(&evsel->name);
> zfree(&evsel->pmu_name);
> + zfree(&evsel->per_pkg_mask);
> + zfree(&evsel->metric_events);
> perf_evsel__object.fini(evsel);
> }
>
> --
> 2.26.2.645.ge9eca65c58-goog
>
--
- Arnaldo
Powered by blists - more mailing lists