mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf machine: Fix NULL deref in thread__resolve_callchain_sample()
@ 2026-10-27 11:47 lv.yating
  2026-10-27 15:21 ` Ian Rogers
  0 siblings, 1 reply; 4+ messages in thread
From: lv.yating @ 2026-10-27 11:47 UTC (permalink / raw)
  To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, irogers, adrian.hunter, james.clark
  Cc: linux-perf-users, linux-kernel, liu.qingtao2, he.yilin,
	zhang.cheng35, ye.zhihao1, shen.lin1, dai.hualiang, stable,
	hu.shengming

From: lvyating <lv.yating@zte.com.cn>

When recording with -j stack, resolve_lbr_callchain_sample() can
dereference a NULL 'chain' pointer while resolving the branch
stack.

$ perf record -j stack -e branches:u uname
perf: Segmentation fault

Fix it by checking 'chain' for NULL before dereferencing it.

Fixes: 29be60c93d2d ("perf build-id: Mark DSO in sample callchains")
Signed-off-by: lvyating <lv.yating@zte.com.cn>
Cc: stable@vger.kernel.org
---
 tools/perf/util/machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index f86b3b7df742..10a88c070814 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2858,7 +2858,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 	if (chain)
 		chain_nr = chain->nr;

-	if (evsel__has_branch_callstack(evsel)) {
+	if (chain && evsel__has_branch_callstack(evsel)) {
 		struct perf_env *env = evsel__env(evsel);

 		err = resolve_lbr_callchain_sample(thread, cursor, sample, parent,
-- 
2.27.0

^ permalink raw reply	[flat|nested] 4+ messages in thread
[parent not found: <2026102719473296875zO7s1T904dguHCkN5vy@zte.com.cn>]

end of thread, other threads:[~2026-10-27 20:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 11:47 [PATCH] perf machine: Fix NULL deref in thread__resolve_callchain_sample() lv.yating
2026-10-27 15:21 ` Ian Rogers
2026-10-27 20:37   ` Arnaldo Carvalho de Melo
     [not found] <2026102719473296875zO7s1T904dguHCkN5vy@zte.com.cn>
2026-10-27 15:51 ` hu.shengming

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

all inboxes | Powered by JetHome®