Skip to content

Commit 0c342bf

Browse files
olsajiriAlexei Starovoitov
authored andcommitted
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: 6302bde ("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>
1 parent 4b2b38e commit 0c342bf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/bpf/trace_helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ int bpf_get_addrs(unsigned long **addrsp, size_t *cntp, bool kernel)
732732

733733
if (cnt == max_cnt) {
734734
max_cnt += inc_cnt;
735-
tmp_addrs = realloc(addrs, max_cnt);
735+
tmp_addrs = realloc(addrs, max_cnt * sizeof(long));
736736
if (!tmp_addrs) {
737737
err = -ENOMEM;
738738
goto error;

0 commit comments

Comments
 (0)