Skip to content

Commit

Permalink
felix/bpf: fix err handling in bpf_program_attach_cgroup
Browse files Browse the repository at this point in the history
As the error is encoded in the link pointer, it it not NULL in case of
an error.
  • Loading branch information
tomastigera committed Jan 26, 2022
1 parent 00a16bf commit bd9ec65
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions felix/bpf/libbpf/libbpf_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ struct bpf_link *bpf_program_attach_cgroup(struct bpf_object *obj, int cgroup_fd
goto out;
}

if (!(link = bpf_program__attach_cgroup(prog, cgroup_fd))) {
err = libbpf_get_error(link);
link = bpf_program__attach_cgroup(prog, cgroup_fd);
err = libbpf_get_error(link);
if (err) {
link = NULL;
goto out;
}

Expand Down

0 comments on commit bd9ec65

Please sign in to comment.