linux-bl808/tools/bpf/bpftool
Quentin Monnet e89ef634f8 bpftool: Avoid leaking the JSON writer prepared for program metadata
Bpftool creates a new JSON object for writing program metadata in plain
text mode, regardless of metadata being present or not. Then this writer
is freed if any metadata has been found and printed, but it leaks
otherwise. We cannot destroy the object unconditionally, because the
destructor prints an undesirable line break. Instead, make sure the
writer is created only after we have found program metadata to print.

Found with valgrind.

Fixes: aff52e685e ("bpftool: Support dumping metadata")
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211022094743.11052-1-quentin@isovalent.com
2021-10-22 16:44:56 -07:00
..
bash-completion
Documentation
skeleton
.gitignore
btf.c bpftool: Switch to new btf__type_cnt API 2021-10-22 16:09:14 -07:00
btf_dumper.c
cfg.c
cfg.h
cgroup.c
common.c
feature.c
gen.c bpftool: Switch to new btf__type_cnt API 2021-10-22 16:09:14 -07:00
iter.c
jit_disasm.c
json_writer.c
json_writer.h
link.c
main.c
main.h
Makefile bpftool: Remove useless #include to <perf-sys.h> from map_perf_ring.c 2021-10-20 10:47:39 -07:00
map.c
map_perf_ring.c bpftool: Remove useless #include to <perf-sys.h> from map_perf_ring.c 2021-10-20 10:47:39 -07:00
net.c
netlink_dumper.c
netlink_dumper.h
perf.c
pids.c
prog.c bpftool: Avoid leaking the JSON writer prepared for program metadata 2021-10-22 16:44:56 -07:00
struct_ops.c
tracelog.c
xlated_dumper.c
xlated_dumper.h