Skip to content

Commit cbf27df

Browse files
committed
libperf evsel: Add missed puts and asserts
JIRA: https://issues.redhat.com/browse/RHEL-78200 upstream ======== commit be59dba Author: Ian Rogers <[email protected]> Date: Tue Jun 17 15:33:56 2025 -0700 description =========== A missed evsel__close before evsel__delete was the source of leaking perf events due to a hybrid test. Add asserts in debug builds so that this shouldn't happen in the future. Add puts missing on the cpu map and thread maps. Signed-off-by: Ian Rogers <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]> Signed-off-by: Anubhav Shelat <[email protected]>
1 parent 5dd60b7 commit cbf27df

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/lib/perf/evsel.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr)
4242

4343
void perf_evsel__delete(struct perf_evsel *evsel)
4444
{
45+
assert(evsel->fd == NULL); /* If not fds were not closed. */
46+
assert(evsel->mmap == NULL); /* If not munmap wasn't called. */
47+
assert(evsel->sample_id == NULL); /* If not free_id wasn't called. */
48+
perf_cpu_map__put(evsel->cpus);
49+
perf_cpu_map__put(evsel->own_cpus);
50+
perf_thread_map__put(evsel->threads);
4551
free(evsel);
4652
}
4753

0 commit comments

Comments
 (0)