提交 bfee71fb 编写于 作者: J Jakub Kicinski 提交者: Daniel Borkmann

tools: bpftool: remember to close the libbpf object after prog load

Remembering to close all descriptors and free memory may not seem
important in a user space tool like bpftool, but if we were to run
in batch mode the consumed resources start to add up quickly.  Make
sure program load closes the libbpf object (which unloads and frees
it).

Fixes: 49a086c2 ("bpftool: implement prog load command")
Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: NQuentin Monnet <quentin.monnet@netronome.com>
Acked-by: NSong Liu <songliubraving@fb.com>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
上级 957f9a13
......@@ -695,12 +695,18 @@ static int do_load(int argc, char **argv)
}
if (do_pin_fd(prog_fd, argv[1]))
return -1;
goto err_close_obj;
if (json_output)
jsonw_null(json_wtr);
bpf_object__close(obj);
return 0;
err_close_obj:
bpf_object__close(obj);
return -1;
}
static int do_help(int argc, char **argv)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册