Skip to content

Commit ccd7574

Browse files
Yang Jihonggregkh
authored andcommitted
perf kwork: Fix incorrect and missing free atom in work_push_atom()
[ Upstream commit d397100 ] 1. Atoms are managed in page mode and should be released using atom_free() instead of free(). 2. When the event does not match, the atom needs to free. Fixes: f98919e ("perf kwork: Implement 'report' subcommand") Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Yang Jihong <yangjihong1@huawei.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Sandipan Das <sandipan.das@amd.com> Cc: Yang Jihong <yangjihong1@huawei.com> Link: https://lore.kernel.org/r/20230812084917.169338-2-yangjihong1@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9546f2a commit ccd7574

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tools/perf/builtin-kwork.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,14 @@ static int work_push_atom(struct perf_kwork *kwork,
406406

407407
work = work_findnew(&class->work_root, &key, &kwork->cmp_id);
408408
if (work == NULL) {
409-
free(atom);
409+
atom_free(atom);
410410
return -1;
411411
}
412412

413-
if (!profile_event_match(kwork, work, sample))
413+
if (!profile_event_match(kwork, work, sample)) {
414+
atom_free(atom);
414415
return 0;
416+
}
415417

416418
if (dst_type < KWORK_TRACE_MAX) {
417419
dst_atom = list_last_entry_or_null(&work->atom_list[dst_type],

0 commit comments

Comments
 (0)