Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf intel-bts: Free the old snapshot reference array after growing it
@ 2026-11-04  2:20 lirongqing
  2026-11-04 10:00 ` James Clark
  0 siblings, 1 reply; 3+ messages in thread
From: lirongqing @ 2026-11-04  2:20 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, James Clark, Li RongQing,
	linux-perf-users, linux-kernel

From: Li RongQing <lirongqing@baidu.com>

The snapshot reference array grows when a mapping index exceeds its
capacity. Its old entries are copied into a new allocation, but the old
array is abandoned when snapshot_refs is replaced.

Release the old array after copying it so expanding past sixteen
mappings does not leak it.

Fixes: d0170af7004d ("perf tools: Add Intel BTS support")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 tools/perf/arch/x86/util/intel-bts.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/arch/x86/util/intel-bts.c b/tools/perf/arch/x86/util/intel-bts.c
index d44d568..9403681 100644
--- a/tools/perf/arch/x86/util/intel-bts.c
+++ b/tools/perf/arch/x86/util/intel-bts.c
@@ -299,6 +299,7 @@ static int intel_bts_alloc_snapshot_refs(struct intel_bts_recording *btsr,
 
 	memcpy(refs, btsr->snapshot_refs, cnt * sz);
 
+	free(btsr->snapshot_refs);
 	btsr->snapshot_refs = refs;
 	btsr->snapshot_ref_cnt = new_cnt;
 
-- 
2.9.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-04 21:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  2:20 [PATCH] perf intel-bts: Free the old snapshot reference array after growing it lirongqing
2026-11-04 10:00 ` James Clark
2026-11-04 21:18   ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox