From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: James Clark <james.clark@linaro.org>
Cc: lirongqing <lirongqing@baidu.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf intel-bts: Free the old snapshot reference array after growing it
Date: Wed, 4 Nov 2026 18:18:25 -0300 [thread overview]
Message-ID: <auuhIWt8Xz9jXBot@phoenix2> (raw)
In-Reply-To: <c1e052c6-531b-4c1e-b671-b5a214ae24c4@linaro.org>
On Wed, Nov 04, 2026 at 10:00:15AM +0000, James Clark wrote:
>
>
> On 04/11/2026 02:20, lirongqing wrote:
> > 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;
>
> I made the same fix here [1] as well as turning BTS snapshots into the
> generic one. But that doesn't have a fixes tag, so maybe this patch is still
> useful.
>
> Reviewed-by: James Clark <james.clark@linaro.org>
>
> [1]: https://lore.kernel.org/all/20261102-james-cs-unformatted-per-thread-fix-v3-10-dbcb0c281b9b@linaro.org/
Thanks, applied for v7.4.
- Arnaldo
prev parent reply other threads:[~2026-11-04 21:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=auuhIWt8Xz9jXBot@phoenix2 \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=lirongqing@baidu.com \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox