aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrii Nakryiko <[email protected]>2023-11-02 03:37:43 +0000
committerAlexei Starovoitov <[email protected]>2023-11-10 02:58:38 +0000
commit2b62aa59d02ed281fa4fc218df3ca91b773e1e62 (patch)
tree686aacd80499a6a90b0418246cf7baab1be1b59f
parentselftests/bpf: Add malloc failure checks in bpf_iter (diff)
downloadkernel-2b62aa59d02ed281fa4fc218df3ca91b773e1e62.tar.gz
kernel-2b62aa59d02ed281fa4fc218df3ca91b773e1e62.zip
selftests/bpf: fix RELEASE=1 build for tc_opts
Compiler complains about malloc(). We also don't need to dynamically allocate anything, so make the life easier by using statically sized buffer. Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
-rw-r--r--tools/testing/selftests/bpf/prog_tests/tc_opts.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/tc_opts.c b/tools/testing/selftests/bpf/prog_tests/tc_opts.c
index 51883ccb8020..196abf223465 100644
--- a/tools/testing/selftests/bpf/prog_tests/tc_opts.c
+++ b/tools/testing/selftests/bpf/prog_tests/tc_opts.c
@@ -2387,12 +2387,9 @@ static int generate_dummy_prog(void)
const size_t prog_insn_cnt = sizeof(prog_insns) / sizeof(struct bpf_insn);
LIBBPF_OPTS(bpf_prog_load_opts, opts);
const size_t log_buf_sz = 256;
- char *log_buf;
+ char log_buf[log_buf_sz];
int fd = -1;
- log_buf = malloc(log_buf_sz);
- if (!ASSERT_OK_PTR(log_buf, "log_buf_alloc"))
- return fd;
opts.log_buf = log_buf;
opts.log_size = log_buf_sz;
@@ -2402,7 +2399,6 @@ static int generate_dummy_prog(void)
prog_insns, prog_insn_cnt, &opts);
ASSERT_STREQ(log_buf, "", "log_0");
ASSERT_GE(fd, 0, "prog_fd");
- free(log_buf);
return fd;
}