]> www.infradead.org Git - users/jedix/linux-maple.git/commit
perf mem: Don't leak mem event names
authorIan Rogers <irogers@google.com>
Sat, 8 Mar 2025 01:28:53 +0000 (17:28 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Mon, 10 Mar 2025 21:26:45 +0000 (14:26 -0700)
commitdb5af2e4a02c9b3744453a84657ed1fc54a1ef82
treef0f602ca90afd91a8e5bb85a613bf1776548c08b
parent6dad43bb114983cab4aa74ae6e13318100447c80
perf mem: Don't leak mem event names

When preparing the mem events for the argv copies are intentionally
made. These copies are leaked and cause runs of perf using address
sanitizer to fail. Rather than leak the memory allocate a chunk of
memory for the mem event names upfront and build the strings in this -
the storage is sized larger than the previous buffer size. The caller
is then responsible for clearing up this memory. As part of this
change, remove the mem_loads_name and mem_stores_name global buffers
then change the perf_pmu__mem_events_name to write to an out argument
buffer.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Thomas Falcon <thomas.falcon@intel.com>
Reviewed-by: Leo Yan <leo.yan@arm.com>
Link: https://lore.kernel.org/r/20250308012853.1384762-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/builtin-c2c.c
tools/perf/builtin-mem.c
tools/perf/util/mem-events.c
tools/perf/util/mem-events.h