summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhihao Cheng <chengzhihao1@huawei.com>2021-06-09 19:59:16 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-07-14 16:53:28 +0200
commit5f543705309fb8f708e92eb0026ae6bad32c9960 (patch)
tree5dc4976dfdad519b89d4c05c1d52d6562f1e2d80
parentfe5cca105794070ae379c41f9a86ec59edc61ad0 (diff)
downloadlinux-stable-5f543705309fb8f708e92eb0026ae6bad32c9960.tar.gz
linux-stable-5f543705309fb8f708e92eb0026ae6bad32c9960.tar.bz2
linux-stable-5f543705309fb8f708e92eb0026ae6bad32c9960.zip
tools/bpftool: Fix error return code in do_batch()
[ Upstream commit ca16b429f39b4ce013bfa7e197f25681e65a2a42 ] Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function. Fixes: 668da745af3c2 ("tools: bpftool: add support for quotations ...") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Quentin Monnet <quentin@isovalent.com> Link: https://lore.kernel.org/bpf/20210609115916.2186872-1-chengzhihao1@huawei.com Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--tools/bpf/bpftool/main.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
index 93d008687020..7d3cfb0ccbe6 100644
--- a/tools/bpf/bpftool/main.c
+++ b/tools/bpf/bpftool/main.c
@@ -303,8 +303,10 @@ static int do_batch(int argc, char **argv)
n_argc = make_args(buf, n_argv, BATCH_ARG_NB_MAX, lines);
if (!n_argc)
continue;
- if (n_argc < 0)
+ if (n_argc < 0) {
+ err = n_argc;
goto err_close;
+ }
if (json_output) {
jsonw_start_object(json_wtr);