Skip to content

Commit 785e76d

Browse files
qmonnetborkmann
authored andcommitted
tools: bpftool: return from do_event_pipe() on bad arguments
When command line parsing fails in the while loop in do_event_pipe() because the number of arguments is incorrect or because the keyword is unknown, an error message is displayed, but bpftool remains stuck in the loop. Make sure we exit the loop upon failure. Fixes: f412eed ("tools: bpftool: add simple perf event output reader") Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent c020347 commit 785e76d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/bpf/bpftool/map_perf_ring.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,10 @@ int do_event_pipe(int argc, char **argv)
194194
}
195195

196196
while (argc) {
197-
if (argc < 2)
197+
if (argc < 2) {
198198
BAD_ARG();
199+
goto err_close_map;
200+
}
199201

200202
if (is_prefix(*argv, "cpu")) {
201203
char *endptr;
@@ -221,6 +223,7 @@ int do_event_pipe(int argc, char **argv)
221223
NEXT_ARG();
222224
} else {
223225
BAD_ARG();
226+
goto err_close_map;
224227
}
225228

226229
do_all = false;

0 commit comments

Comments
 (0)