Skip to content

Commit c114903

Browse files
captain5050namhyung
authored andcommitted
perf hist: Add missing puts to hist__account_cycles
Caught using reference count checking on perf top with "--call-graph=lbr". After this no memory leaks were detected. Fixes: 5784999 ("perf report: Add processing for cycle histograms") 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-6-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 78c32f4 commit c114903

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

tools/perf/util/hist.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,8 +2676,6 @@ void hist__account_cycles(struct branch_stack *bs, struct addr_location *al,
26762676

26772677
/* If we have branch cycles always annotate them. */
26782678
if (bs && bs->nr && entries[0].flags.cycles) {
2679-
int i;
2680-
26812679
bi = sample__resolve_bstack(sample, al);
26822680
if (bi) {
26832681
struct addr_map_symbol *prev = NULL;
@@ -2692,7 +2690,7 @@ void hist__account_cycles(struct branch_stack *bs, struct addr_location *al,
26922690
* Note that perf stores branches reversed from
26932691
* program order!
26942692
*/
2695-
for (i = bs->nr - 1; i >= 0; i--) {
2693+
for (int i = bs->nr - 1; i >= 0; i--) {
26962694
addr_map_symbol__account_cycles(&bi[i].from,
26972695
nonany_branch_mode ? NULL : prev,
26982696
bi[i].flags.cycles);
@@ -2701,6 +2699,12 @@ void hist__account_cycles(struct branch_stack *bs, struct addr_location *al,
27012699
if (total_cycles)
27022700
*total_cycles += bi[i].flags.cycles;
27032701
}
2702+
for (unsigned int i = 0; i < bs->nr; i++) {
2703+
map__put(bi[i].to.ms.map);
2704+
maps__put(bi[i].to.ms.maps);
2705+
map__put(bi[i].from.ms.map);
2706+
maps__put(bi[i].from.ms.maps);
2707+
}
27042708
free(bi);
27052709
}
27062710
}

0 commit comments

Comments
 (0)