summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2025-10-01 14:22:23 +0200
committerAlexei Starovoitov <ast@kernel.org>2025-10-01 13:37:30 -0700
commit0c342bfc9949dffeaa83ebdde3b4b0ce59009348 (patch)
treed9ecf01a61cfb80360ba9b895ce67b65d81a6385
parent4b2b38ea20567d842607b7bca6d618d154c78d84 (diff)
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>
-rw-r--r--tools/testing/selftests/bpf/trace_helpers.c2
1 files changed, 1 insertions, 1 deletions
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;