perf evsel: Fix memory leaks relating to unit
authorIan Rogers <irogers@google.com>
Thu, 18 Nov 2021 08:47:49 +0000 (00:47 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 18 Nov 2021 13:19:14 +0000 (10:19 -0300)
commitb194c9cd09dd98af76beaa32a041af674260d730
tree528463fa6a7d4fb545e0164d4addef84d7c64df3
parentd9fc706108c15f8bc2d4ccccf8e50f74830fabd9
perf evsel: Fix memory leaks relating to unit

unit may have a strdup pointer or be to a literal, consequently memory
assocciated with it isn't freed. Change it so the unit is always strdup
and so the memory can be safely freed.

Fix related issue in perf_event__process_event_update() for name and
own_cpus. Leaks were spotted by leak sanitizer.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.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/20211118084749.2191447-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/event_update.c
tools/perf/util/evsel.c
tools/perf/util/header.c
tools/perf/util/parse-events.c