]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tools/bpftool: Fix error return code in do_batch()
authorZhihao Cheng <chengzhihao1@huawei.com>
Wed, 9 Jun 2021 11:59:16 +0000 (19:59 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:15:49 +0000 (16:15 +0200)
[ 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>
tools/bpf/bpftool/main.c

index d15a62be6cf0fd0bbe306e9420fc07d9848ce679..37610144f6b08b7f33064af9111928e4edd19425 100644 (file)
@@ -291,8 +291,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);