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>
This commit is contained in:
Ian Rogers 2023-10-24 15:23:10 -07:00 committed by Namhyung Kim
parent 7b2e444b76
commit 67a3ebf1c3

View file

@ -98,22 +98,22 @@ static void off_cpu_finish(void *arg __maybe_unused)
/* v5.18 kernel added prev_state arg, so it needs to check the signature */ /* v5.18 kernel added prev_state arg, so it needs to check the signature */
static void check_sched_switch_args(void) static void check_sched_switch_args(void)
{ {
const struct btf *btf = btf__load_vmlinux_btf(); struct btf *btf = btf__load_vmlinux_btf();
const struct btf_type *t1, *t2, *t3; const struct btf_type *t1, *t2, *t3;
u32 type_id; u32 type_id;
type_id = btf__find_by_name_kind(btf, "btf_trace_sched_switch", type_id = btf__find_by_name_kind(btf, "btf_trace_sched_switch",
BTF_KIND_TYPEDEF); BTF_KIND_TYPEDEF);
if ((s32)type_id < 0) if ((s32)type_id < 0)
return; goto cleanup;
t1 = btf__type_by_id(btf, type_id); t1 = btf__type_by_id(btf, type_id);
if (t1 == NULL) if (t1 == NULL)
return; goto cleanup;
t2 = btf__type_by_id(btf, t1->type); t2 = btf__type_by_id(btf, t1->type);
if (t2 == NULL || !btf_is_ptr(t2)) if (t2 == NULL || !btf_is_ptr(t2))
return; goto cleanup;
t3 = btf__type_by_id(btf, t2->type); t3 = btf__type_by_id(btf, t2->type);
/* btf_trace func proto has one more argument for the context */ /* btf_trace func proto has one more argument for the context */
@ -121,6 +121,8 @@ static void check_sched_switch_args(void)
/* new format: pass prev_state as 4th arg */ /* new format: pass prev_state as 4th arg */
skel->rodata->has_prev_state = true; skel->rodata->has_prev_state = true;
} }
cleanup:
btf__free(btf);
} }
int off_cpu_prepare(struct evlist *evlist, struct target *target, int off_cpu_prepare(struct evlist *evlist, struct target *target,