aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2024-09-30 22:23:25 -0700
committerNamhyung Kim <namhyung@kernel.org>2024-10-02 14:58:03 -0700
commit1334ee91694c21777d2df1da20bc5d5a7022a1e5 (patch)
tree59e3a21fe1be9336adefecad0e2775d46867e74c
parentperf stat: Fix affinity memory leaks on error path (diff)
downloadwireguard-linux-1334ee91694c21777d2df1da20bc5d5a7022a1e5.tar.xz
wireguard-linux-1334ee91694c21777d2df1da20bc5d5a7022a1e5.zip
perf test: Fix memory leaks on event-times error paths
These error paths occur without sufficient permissions. Fix the memory leaks to make leak sanitizer happier. Signed-off-by: Ian Rogers <irogers@google.com> Link: https://lore.kernel.org/r/20241001052327.7052-3-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
-rw-r--r--tools/perf/tests/event-times.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c
index e155f0e0e04d..deefe5003bfc 100644
--- a/tools/perf/tests/event-times.c
+++ b/tools/perf/tests/event-times.c
@@ -126,6 +126,7 @@ static int attach__cpu_disabled(struct evlist *evlist)
evsel->core.attr.disabled = 1;
err = evsel__open_per_cpu(evsel, cpus, -1);
+ perf_cpu_map__put(cpus);
if (err) {
if (err == -EACCES)
return TEST_SKIP;
@@ -134,7 +135,6 @@ static int attach__cpu_disabled(struct evlist *evlist)
return err;
}
- perf_cpu_map__put(cpus);
return evsel__enable(evsel);
}
@@ -153,10 +153,10 @@ static int attach__cpu_enabled(struct evlist *evlist)
}
err = evsel__open_per_cpu(evsel, cpus, -1);
+ perf_cpu_map__put(cpus);
if (err == -EACCES)
return TEST_SKIP;
- perf_cpu_map__put(cpus);
return err ? TEST_FAIL : TEST_OK;
}
@@ -188,6 +188,7 @@ static int test_times(int (attach)(struct evlist *),
err = attach(evlist);
if (err == TEST_SKIP) {
pr_debug(" SKIP : not enough rights\n");
+ evlist__delete(evlist);
return err;
}