From: Mark Korenberg "bpftool prog dump jited PROG file FILE" only writes the JITed image to FILE, but do_dump() calls disasm_init() before it parses the arguments, so the command fails when bpftool has no disassembler. Call disasm_init() only when the image is disassembled. Fixes: 29a9c10e4110 ("bpftool: make libbfd optional") Suggested-by: Alexei Starovoitov Signed-off-by: Mark Korenberg --- tools/bpf/bpftool/prog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index 43599c79c93ac..15efc6eebffb1 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -894,8 +894,6 @@ static int do_dump(int argc, char **argv) int err = -1; if (is_prefix(*argv, "jited")) { - if (disasm_init()) - return -1; mode = DUMP_JITED; } else if (is_prefix(*argv, "xlated")) { mode = DUMP_XLATED; @@ -959,6 +957,8 @@ static int do_dump(int argc, char **argv) p_err("'visual' is not compatible with JSON output"); goto exit_close; } + if (mode == DUMP_JITED && !filepath && disasm_init()) + goto exit_close; if (json_output && nb_fds > 1) jsonw_start_array(json_wtr); /* root array */ -- 2.56.0