* [PATCH v2] bpf: bpftool: Setting error code in do_loader()
@ 2025-03-11 3:12 Sewon Nam
2025-03-11 10:02 ` Quentin Monnet
0 siblings, 1 reply; 2+ messages in thread
From: Sewon Nam @ 2025-03-11 3:12 UTC (permalink / raw)
To: Quentin Monnet, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
Hao Luo, Jiri Olsa
Cc: Sewon Nam, bpf, linux-kernel
missing error code in do_loader()
bpf_object__open_file() failed, but return 0
This means the command's exit status code was successful, so make sure to return the correct error code.
To maintain consistency with other locations where bpf_object__open_file() is called, it returns -1 instead.
Link: https://lore.kernel.org/bpf/d3b5b4b4-19bb-4619-b4dd-86c958c4a367@stanley.mountain/t/#u
Closes: https://github.com/libbpf/bpftool/issues/156
Signed-off-by: Sewon Nam <swnam0729@gmail.com>
---
tools/bpf/bpftool/prog.c | 1 +
1 file changed, 1 insertion(+)
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;
}
--
2.39.3 (Apple Git-146)
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] bpf: bpftool: Setting error code in do_loader()
2025-03-11 3:12 [PATCH v2] bpf: bpftool: Setting error code in do_loader() Sewon Nam
@ 2025-03-11 10:02 ` Quentin Monnet
0 siblings, 0 replies; 2+ messages in thread
From: Quentin Monnet @ 2025-03-11 10:02 UTC (permalink / raw)
To: Sewon Nam, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa
Cc: bpf, linux-kernel, Dan Carpenter
2025-03-11 12:12 UTC+0900 ~ Sewon Nam <swnam0729@gmail.com>
> missing error code in do_loader()
> bpf_object__open_file() failed, but return 0
> This means the command's exit status code was successful, so make sure to return the correct error code.
> To maintain consistency with other locations where bpf_object__open_file() is called, it returns -1 instead.
Nit: Please wrap long lines in the commit description next time you send
a patch.
>
> Link: https://lore.kernel.org/bpf/d3b5b4b4-19bb-4619-b4dd-86c958c4a367@stanley.mountain/t/#u
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://github.com/libbpf/bpftool/issues/156
> Signed-off-by: Sewon Nam <swnam0729@gmail.com>
Tested-by: Quentin Monnet <qmo@kernel.org>
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Thank you!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-11 10:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-11 3:12 [PATCH v2] bpf: bpftool: Setting error code in do_loader() Sewon Nam
2025-03-11 10:02 ` Quentin Monnet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox