Skip to content

Commit 46df1fe

Browse files
nswongregkh
authored andcommitted
bpf: bpftool: Setting error code in do_loader()
[ Upstream commit 02a4694 ] 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: libbpf/bpftool#156 Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Sewon Nam <swnam0729@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Tested-by: Quentin Monnet <qmo@kernel.org> Reviewed-by: Quentin Monnet <qmo@kernel.org> Link: https://lore.kernel.org/bpf/d3b5b4b4-19bb-4619-b4dd-86c958c4a367@stanley.mountain/t/#u Link: https://lore.kernel.org/bpf/20250311031238.14865-1-swnam0729@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ab57877 commit 46df1fe

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

tools/bpf/bpftool/prog.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@ static int do_loader(int argc, char **argv)
19281928

19291929
obj = bpf_object__open_file(file, &open_opts);
19301930
if (!obj) {
1931+
err = -1;
19311932
p_err("failed to open object file");
19321933
goto err_close_obj;
19331934
}

0 commit comments

Comments
 (0)