diff options
author | Quentin Monnet <quentin.monnet@netronome.com> | 2018-08-23 17:46:25 +0100 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-08-23 20:17:57 +0200 |
commit | 785e76d7a2051a9e28b9134d5388a45b16f5eb72 (patch) | |
tree | e1980af4eeb23ce968466601262e889b41bc3fed /tools/bpf/bpftool | |
parent | c0203475765f827e7b2eaf0a87222d0766e2cc4b (diff) | |
download | linux-785e76d7a2051a9e28b9134d5388a45b16f5eb72.tar.bz2 |
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: f412eed9dfde ("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>
Diffstat (limited to 'tools/bpf/bpftool')
-rw-r--r-- | tools/bpf/bpftool/map_perf_ring.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/map_perf_ring.c b/tools/bpf/bpftool/map_perf_ring.c index 1832100d1b27..6d41323be291 100644 --- a/tools/bpf/bpftool/map_perf_ring.c +++ b/tools/bpf/bpftool/map_perf_ring.c @@ -194,8 +194,10 @@ int do_event_pipe(int argc, char **argv) } while (argc) { - if (argc < 2) + if (argc < 2) { BAD_ARG(); + goto err_close_map; + } if (is_prefix(*argv, "cpu")) { char *endptr; @@ -221,6 +223,7 @@ int do_event_pipe(int argc, char **argv) NEXT_ARG(); } else { BAD_ARG(); + goto err_close_map; } do_all = false; |