bpf: prevent double-close

parent 8c49586f
...@@ -67,10 +67,7 @@ void bpf_program_free(struct bpf_program *prog) ...@@ -67,10 +67,7 @@ void bpf_program_free(struct bpf_program *prog)
(void)bpf_program_cgroup_detach(prog); (void)bpf_program_cgroup_detach(prog);
if (prog->kernel_fd >= 0)
close(prog->kernel_fd);
free(prog->instructions); free(prog->instructions);
close_prot_errno_disarm(prog->fd_cgroup);
free(prog); free(prog);
} }
...@@ -437,8 +434,8 @@ int bpf_program_cgroup_detach(struct bpf_program *prog) ...@@ -437,8 +434,8 @@ int bpf_program_cgroup_detach(struct bpf_program *prog)
return 0; return 0;
/* Ensure that these fds are wiped. */ /* Ensure that these fds are wiped. */
fd_cgroup = prog->fd_cgroup; fd_cgroup = move_fd(prog->fd_cgroup);
fd_kernel = prog->kernel_fd; fd_kernel = move_fd(prog->kernel_fd);
if (fd_cgroup < 0 || fd_kernel < 0) if (fd_cgroup < 0 || fd_kernel < 0)
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