Skip to content

Commit

Permalink
tools: bpf: handle NULL return in bpf_prog_load_xattr()
Browse files Browse the repository at this point in the history
bpf_object__open() can return error pointer as well as NULL.
Fix error handling in bpf_prog_load_xattr() (and indirectly
bpf_prog_load()).

Fixes: 6f6d33f ("bpf: selftests add sockmap tests")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  • Loading branch information
Jakub Kicinski authored and Daniel Borkmann committed May 10, 2018
1 parent 26aeb9d commit 3597683
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/lib/bpf/libbpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,7 @@ int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr,
return -EINVAL;

obj = bpf_object__open(attr->file);
if (IS_ERR(obj))
if (IS_ERR_OR_NULL(obj))
return -ENOENT;

bpf_object__for_each_program(prog, obj) {
Expand Down

0 comments on commit 3597683

Please sign in to comment.