parent 3b5796aa
...@@ -325,6 +325,9 @@ static int bpf_program_load_kernel(struct bpf_program *prog, char *log_buf, ...@@ -325,6 +325,9 @@ static int bpf_program_load_kernel(struct bpf_program *prog, char *log_buf,
{ {
union bpf_attr attr; union bpf_attr attr;
if ((log_size != 0 && !log_buf) || (log_size == 0 && log_buf))
return ret_errno(EINVAL);
if (prog->kernel_fd >= 0) { if (prog->kernel_fd >= 0) {
memset(log_buf, 0, log_size); memset(log_buf, 0, log_size);
return 0; return 0;
...@@ -342,9 +345,10 @@ static int bpf_program_load_kernel(struct bpf_program *prog, char *log_buf, ...@@ -342,9 +345,10 @@ static int bpf_program_load_kernel(struct bpf_program *prog, char *log_buf,
prog->kernel_fd = bpf(BPF_PROG_LOAD, &attr, sizeof(attr)); prog->kernel_fd = bpf(BPF_PROG_LOAD, &attr, sizeof(attr));
if (prog->kernel_fd < 0) if (prog->kernel_fd < 0)
return log_error_errno(-1, errno, "Failed to load bpf program: %s", log_buf); return log_error_errno(-1, errno, "Failed to load bpf program: %s",
log_buf ?: "(null)");
TRACE("Loaded bpf program: %s", log_buf); TRACE("Loaded bpf program: %s", log_buf ?: "(null)");
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment