[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <159056888305.330763.9684536967379110349.stgit@ebuild>
Date: Wed, 27 May 2020 10:42:00 +0200
From: Eelco Chaudron <echaudro@...hat.com>
To: bpf@...r.kernel.org
Cc: davem@...emloft.net, netdev@...r.kernel.org, ast@...nel.org,
daniel@...earbox.net, kafai@...com, songliubraving@...com,
yhs@...com, andriin@...com, toke@...hat.com
Subject: [PATCH bpf-next] libbpf: fix perf_buffer__free() API for sparse allocs
In case the cpu_bufs are sparsely allocated they are not
all free'ed. These changes will fix this.
Signed-off-by: Eelco Chaudron <echaudro@...hat.com>
---
tools/lib/bpf/libbpf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 5d60de6fd818..74d967619dcf 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -8137,9 +8137,12 @@ void perf_buffer__free(struct perf_buffer *pb)
if (!pb)
return;
if (pb->cpu_bufs) {
- for (i = 0; i < pb->cpu_cnt && pb->cpu_bufs[i]; i++) {
+ for (i = 0; i < pb->cpu_cnt; i++) {
struct perf_cpu_buf *cpu_buf = pb->cpu_bufs[i];
+ if (!cpu_buf)
+ continue;
+
bpf_map_delete_elem(pb->map_fd, &cpu_buf->map_key);
perf_buffer__free_cpu_buf(pb, cpu_buf);
}
Powered by blists - more mailing lists