From: Jiri Olsa Date: Wed, 1 Oct 2025 12:22:23 +0000 (+0200) Subject: selftests/bpf: Fix realloc size in bpf_get_addrs X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0c342bfc9949dffeaa83ebdde3b4b0ce59009348;p=thirdparty%2Fkernel%2Fstable.git 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 Signed-off-by: Alexei Starovoitov --- diff --git a/tools/testing/selftests/bpf/trace_helpers.c b/tools/testing/selftests/bpf/trace_helpers.c index 171987627f3a..eeaab7013ca2 100644 --- a/tools/testing/selftests/bpf/trace_helpers.c +++ b/tools/testing/selftests/bpf/trace_helpers.c @@ -732,7 +732,7 @@ int bpf_get_addrs(unsigned long **addrsp, size_t *cntp, bool kernel) if (cnt == max_cnt) { max_cnt += inc_cnt; - tmp_addrs = realloc(addrs, max_cnt); + tmp_addrs = realloc(addrs, max_cnt * sizeof(long)); if (!tmp_addrs) { err = -ENOMEM; goto error;