diff options
| author | Sewon Nam <[email protected]> | 2025-03-11 03:12:37 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2025-03-15 18:48:58 +0000 |
| commit | 02a4694107b4c830d4bd6d194e98b3ac0bc86f29 (patch) | |
| tree | 5d2030fbb49b1b0d4ab3a91b108635837a04c266 /tools/bpf/bpftool/prog.c | |
| parent | Merge branch 'security-propagate-caller-information-in-bpf-hooks' (diff) | |
| download | kernel-02a4694107b4c830d4bd6d194e98b3ac0bc86f29.tar.gz kernel-02a4694107b4c830d4bd6d194e98b3ac0bc86f29.zip | |
bpf: bpftool: Setting error code in do_loader()
We are missing setting error code in do_loader() when
bpf_object__open_file() fails. This means the command's exit status code
will be successful, even though the operation failed. So make sure to
return the correct error code. To maintain consistency with other
locations where bpf_object__open_file() is called, return -1.
[0] Closes: https://github.com/libbpf/bpftool/issues/156
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Sewon Nam <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Tested-by: Quentin Monnet <[email protected]>
Reviewed-by: Quentin Monnet <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]/t/#u
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
Diffstat (limited to 'tools/bpf/bpftool/prog.c')
| -rw-r--r-- | tools/bpf/bpftool/prog.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index e71be67f1d86..52ffb74ae4e8 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -1928,6 +1928,7 @@ static int do_loader(int argc, char **argv) obj = bpf_object__open_file(file, &open_opts); if (!obj) { + err = -1; p_err("failed to open object file"); goto err_close_obj; } |
