diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2021-11-24 03:23:20 +0300 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2021-11-26 02:15:03 +0300 |
commit | 3bd0233f388e061c44d36a1ac614a3bb4a851b7e (patch) | |
tree | dac7834cbccc83310aa9c8a2d15b42f4c296ead2 /tools | |
parent | 486e648cb2f170702fc05f777c7b6b3d8ec662ce (diff) | |
download | linux-3bd0233f388e061c44d36a1ac614a3bb4a851b7e.tar.xz |
selftests/bpf: Fix possible NULL passed to memcpy() with zero size
Prevent sanitizer from complaining about passing NULL into memcpy(),
even if it happens with zero size.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20211124002325.1737739-9-andrii@kernel.org
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/bpf/prog_tests/core_reloc.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/core_reloc.c b/tools/testing/selftests/bpf/prog_tests/core_reloc.c index 1041d0c593f6..44a9868c70ea 100644 --- a/tools/testing/selftests/bpf/prog_tests/core_reloc.c +++ b/tools/testing/selftests/bpf/prog_tests/core_reloc.c @@ -881,7 +881,8 @@ void test_core_reloc(void) data = mmap_data; memset(mmap_data, 0, sizeof(*data)); - memcpy(data->in, test_case->input, test_case->input_len); + if (test_case->input_len) + memcpy(data->in, test_case->input, test_case->input_len); data->my_pid_tgid = my_pid_tgid; link = bpf_program__attach_raw_tracepoint(prog, tp_name); |