perf header: Fix memory leaks when processing feature headers
authorIan Rogers <irogers@google.com>
Thu, 18 Nov 2021 20:17:30 +0000 (12:17 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 7 Dec 2021 00:57:53 +0000 (21:57 -0300)
commit4747395082abc67c700a75e4cf3b796e79c7cf3a
tree550d5da07283546d61e35bef86d74c2a95c2f001
parent1aa79e57730980dfbabd44e7c0a12fbb56064cb6
perf header: Fix memory leaks when processing feature headers

These leaks were found with leak sanitizer running "perf pipe recording
and injection test".

In pipe mode feat_fd may hold onto an events struct that needs freeing.

When string features are processed they may overwrite an already created
string, so free this before the overwrite.

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