Skip to content

Commit 88e4823

Browse files
smalinuxacmel
authored andcommitted
perf bench futex: Fix memory leak of perf_cpu_map__new()
ASan reports memory leaks while running: $ sudo ./perf bench futex all The leaks are caused by perf_cpu_map__new not being freed. This patch adds the missing perf_cpu_map__put since it calls cpu_map_delete implicitly. Fixes: 9c3516d ("libperf: Add perf_cpu_map__new()/perf_cpu_map__read() functions") Signed-off-by: Sohaib Mohamed <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: André Almeida <[email protected]> Cc: Darren Hart <[email protected]> Cc: Davidlohr Bueso <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Sohaib Mohamed <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 3442b5e commit 88e4823

File tree

4 files changed

+4
-0
lines changed

4 files changed

+4
-0
lines changed

tools/perf/bench/futex-lock-pi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ int bench_futex_lock_pi(int argc, const char **argv)
233233
print_summary();
234234

235235
free(worker);
236+
perf_cpu_map__put(cpu);
236237
return ret;
237238
err:
238239
usage_with_options(bench_futex_lock_pi_usage, options);

tools/perf/bench/futex-requeue.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ int bench_futex_requeue(int argc, const char **argv)
294294
print_summary();
295295

296296
free(worker);
297+
perf_cpu_map__put(cpu);
297298
return ret;
298299
err:
299300
usage_with_options(bench_futex_requeue_usage, options);

tools/perf/bench/futex-wake-parallel.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ int bench_futex_wake_parallel(int argc, const char **argv)
329329
print_summary();
330330

331331
free(blocked_worker);
332+
perf_cpu_map__put(cpu);
332333
return ret;
333334
}
334335
#endif /* HAVE_PTHREAD_BARRIER */

tools/perf/bench/futex-wake.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,5 +222,6 @@ int bench_futex_wake(int argc, const char **argv)
222222
print_summary();
223223

224224
free(worker);
225+
perf_cpu_map__put(cpu);
225226
return ret;
226227
}

0 commit comments

Comments
 (0)