diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2018-06-21 23:07:13 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-06-21 23:07:14 +0200 |
commit | f2e72a0b79a03c4046f08515d1479f613f2eb139 (patch) | |
tree | f8f65c36f80791edb98c219fa98f24c904d28741 /tools | |
parent | 3739a21e0ef6ac06f46bd38e81daa95e8cb462bc (diff) | |
parent | bfee71fb7376081349117fdc89f685a9e14a58c2 (diff) |
Merge branch 'bpf-bpftool-fixes'
Jakub Kicinski says:
====================
Two small fixes for error handling in bpftool prog load, first patch
removes a duplicated message, second one frees resources correctly.
Multiple error messages break JSON:
{
"error": "can't pin the object (/sys/fs/bpf/a): File exists"
},{
"error": "failed to pin program"
}
====================
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bpf/bpftool/prog.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index 05f42a46d6ed..959aa53ab678 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -694,15 +694,19 @@ static int do_load(int argc, char **argv) return -1; } - if (do_pin_fd(prog_fd, argv[1])) { - p_err("failed to pin program"); - return -1; - } + if (do_pin_fd(prog_fd, argv[1])) + goto err_close_obj; if (json_output) jsonw_null(json_wtr); + bpf_object__close(obj); + return 0; + +err_close_obj: + bpf_object__close(obj); + return -1; } static int do_help(int argc, char **argv) |