tools/bpftool: Fix error return code in do_batch()

Started by Zhihao Cheng on Jun 9, 2021 · 3 messages from 3 authors · Last reply Jun 15, 2021

Subsystems (3)

Maintainers (7)

Show 3 more
STALE1989d LANDED

Status: Landed in mainline as ca16b429f39b on 2021-06-11.

open the first message on its own page

Message details and related content
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 <redacted>
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
 tools/bpf/bpftool/main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
index 7f2817d97079..3ddfd4843738 100644
--- a/tools/bpf/bpftool/main.c
+++ b/tools/bpf/bpftool/main.c
@@ -341,8 +341,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);
-- 
2.31.1
Message details and related content
2021-06-09 19:59 UTC+0800 ~ Zhihao Cheng [off-list ref]
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 <redacted>
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: Quentin Monnet <redacted>

Thank you for the fix.
Quentin
Message details and related content
On Wed, Jun 9, 2021 at 6:34 AM Quentin Monnet [off-list ref] wrote:
2021-06-09 19:59 UTC+0800 ~ Zhihao Cheng [off-list ref]
quoted
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 <redacted>
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: Quentin Monnet <redacted>

Thank you for the fix.
This has been applied to bpf-next last Friday. Patchbot missed it.
Quentin
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help