Skip to content

Commit 67a3ebf

Browse files
captain5050namhyung
authored andcommitted
perf offcpu: Add missed btf_free
Caught by address/leak sanitizer. Signed-off-by: Ian Rogers <irogers@google.com> Cc: K Prateek Nayak <kprateek.nayak@amd.com> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Sandipan Das <sandipan.das@amd.com> Cc: Anshuman Khandual <anshuman.khandual@arm.com> Cc: German Gomez <german.gomez@arm.com> Cc: James Clark <james.clark@arm.com> Cc: Nick Terrell <terrelln@fb.com> Cc: Sean Christopherson <seanjc@google.com> Cc: Changbin Du <changbin.du@huawei.com> Cc: liuwenyu <liuwenyu7@huawei.com> Cc: Yang Jihong <yangjihong1@huawei.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Miguel Ojeda <ojeda@kernel.org> Cc: Song Liu <song@kernel.org> Cc: Leo Yan <leo.yan@linaro.org> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Cc: Yanteng Si <siyanteng@loongson.cn> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Link: https://lore.kernel.org/r/20231024222353.3024098-8-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 7b2e444 commit 67a3ebf

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

tools/perf/util/bpf_off_cpu.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,29 +98,31 @@ static void off_cpu_finish(void *arg __maybe_unused)
9898
/* v5.18 kernel added prev_state arg, so it needs to check the signature */
9999
static void check_sched_switch_args(void)
100100
{
101-
const struct btf *btf = btf__load_vmlinux_btf();
101+
struct btf *btf = btf__load_vmlinux_btf();
102102
const struct btf_type *t1, *t2, *t3;
103103
u32 type_id;
104104

105105
type_id = btf__find_by_name_kind(btf, "btf_trace_sched_switch",
106106
BTF_KIND_TYPEDEF);
107107
if ((s32)type_id < 0)
108-
return;
108+
goto cleanup;
109109

110110
t1 = btf__type_by_id(btf, type_id);
111111
if (t1 == NULL)
112-
return;
112+
goto cleanup;
113113

114114
t2 = btf__type_by_id(btf, t1->type);
115115
if (t2 == NULL || !btf_is_ptr(t2))
116-
return;
116+
goto cleanup;
117117

118118
t3 = btf__type_by_id(btf, t2->type);
119119
/* btf_trace func proto has one more argument for the context */
120120
if (t3 && btf_is_func_proto(t3) && btf_vlen(t3) == 5) {
121121
/* new format: pass prev_state as 4th arg */
122122
skel->rodata->has_prev_state = true;
123123
}
124+
cleanup:
125+
btf__free(btf);
124126
}
125127

126128
int off_cpu_prepare(struct evlist *evlist, struct target *target,

0 commit comments

Comments
 (0)