Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Fix realloc size in bpf_get_addrs

We will segfault once we call realloc in bpf_get_addrs due to
wrong size argument.

Fixes: 6302bdeb91df ("selftests/bpf: Add a kprobe_multi subtest to use addrs instead of syms")
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Jiri Olsa and committed by
Alexei Starovoitov
0c342bfc 4b2b38ea

+1 -1
+1 -1
tools/testing/selftests/bpf/trace_helpers.c
··· 732 732 733 733 if (cnt == max_cnt) { 734 734 max_cnt += inc_cnt; 735 - tmp_addrs = realloc(addrs, max_cnt); 735 + tmp_addrs = realloc(addrs, max_cnt * sizeof(long)); 736 736 if (!tmp_addrs) { 737 737 err = -ENOMEM; 738 738 goto error;