Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+8 -4
+8 -4
tools/bpf/bpftool/prog.c
··· 694 694 return -1; 695 695 } 696 696 697 - if (do_pin_fd(prog_fd, argv[1])) { 698 - p_err("failed to pin program"); 699 - return -1; 700 - } 697 + if (do_pin_fd(prog_fd, argv[1])) 698 + goto err_close_obj; 701 699 702 700 if (json_output) 703 701 jsonw_null(json_wtr); 704 702 703 + bpf_object__close(obj); 704 + 705 705 return 0; 706 + 707 + err_close_obj: 708 + bpf_object__close(obj); 709 + return -1; 706 710 } 707 711 708 712 static int do_help(int argc, char **argv)