Skip to content

Commit 8fa1bcc

Browse files
cppcoffeedkruces
authored andcommitted
libbpf-tools/memleak: mmap allocation failed, not added to pointer map (iovisor#5138)
If mmap allocation failed, the address will not be added to pointer map. Signed-off-by: Xiaobo Liu <[email protected]>
1 parent e23168c commit 8fa1bcc

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

libbpf-tools/memleak.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static int gen_alloc_exit2(void *ctx, u64 address)
119119
info.size = *size;
120120
bpf_map_delete_elem(&sizes, &tid);
121121

122-
if (address != 0) {
122+
if (address != 0 && address != MAP_FAILED) {
123123
info.timestamp_ns = bpf_ktime_get_ns();
124124

125125
info.stack_id = bpf_get_stackid(ctx, &stack_traces, stack_flags);

libbpf-tools/memleak.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#define ALLOCS_MAX_ENTRIES 1000000
66
#define COMBINED_ALLOCS_MAX_ENTRIES 10240
7+
#define MAP_FAILED -1
78

89
struct alloc_info {
910
__u64 size;

0 commit comments

Comments
 (0)