Message ID | 20211106053733.3580931-2-irogers@google.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | [1/2] perf bpf: Avoid memory leak from perf_env__insert_btf | expand |
Context | Check | Description |
---|---|---|
bpf/vmtest-bpf-next-PR | success | PR summary |
bpf/vmtest-bpf | success | VM_Test |
bpf/vmtest-bpf-PR | success | PR summary |
bpf/vmtest-bpf-next | success | VM_Test |
netdev/tree_selection | success | Not a local patch |
Em Fri, Nov 05, 2021 at 10:37:33PM -0700, Ian Rogers escreveu: > If btf__new is called then there needs to be a corresponding btf__free. Thanks, applied. - Arnaldo > Fixes: f8dfeae009ef ("perf bpf: Show more BPF program info in print_bpf_prog_info()") > Signed-off-by: Ian Rogers <irogers@google.com> > --- > tools/perf/util/bpf-event.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c > index 0783b464777a..1f813d8bb946 100644 > --- a/tools/perf/util/bpf-event.c > +++ b/tools/perf/util/bpf-event.c > @@ -579,7 +579,7 @@ void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info, > synthesize_bpf_prog_name(name, KSYM_NAME_LEN, info, btf, 0); > fprintf(fp, "# bpf_prog_info %u: %s addr 0x%llx size %u\n", > info->id, name, prog_addrs[0], prog_lens[0]); > - return; > + goto out; > } > > fprintf(fp, "# bpf_prog_info %u:\n", info->id); > @@ -589,4 +589,6 @@ void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info, > fprintf(fp, "# \tsub_prog %u: %s addr 0x%llx size %u\n", > i, name, prog_addrs[i], prog_lens[i]); > } > +out: > + btf__free(btf); > } > -- > 2.34.0.rc0.344.g81b53c2807-goog
diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c index 0783b464777a..1f813d8bb946 100644 --- a/tools/perf/util/bpf-event.c +++ b/tools/perf/util/bpf-event.c @@ -579,7 +579,7 @@ void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info, synthesize_bpf_prog_name(name, KSYM_NAME_LEN, info, btf, 0); fprintf(fp, "# bpf_prog_info %u: %s addr 0x%llx size %u\n", info->id, name, prog_addrs[0], prog_lens[0]); - return; + goto out; } fprintf(fp, "# bpf_prog_info %u:\n", info->id); @@ -589,4 +589,6 @@ void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info, fprintf(fp, "# \tsub_prog %u: %s addr 0x%llx size %u\n", i, name, prog_addrs[i], prog_lens[i]); } +out: + btf__free(btf); }
If btf__new is called then there needs to be a corresponding btf__free. Fixes: f8dfeae009ef ("perf bpf: Show more BPF program info in print_bpf_prog_info()") Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/util/bpf-event.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)