linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf/x86/intel/pt: Fix NULL pointer dereference in pt_buffer_reset_markers
@ 2024-10-01  8:27 Qianqiang Liu
  2024-10-24 11:16 ` Alexander Shishkin
  0 siblings, 1 reply; 3+ messages in thread
From: Qianqiang Liu @ 2024-10-01  8:27 UTC (permalink / raw)
  To: namhyung
  Cc: alexander.shishkin, linux-perf-users, linux-kernel, Qianqiang Liu

The buf->stop_te and buf->intr_te may be NULL, so we need to check
for NULL pointers before using them.

Fixes: 39152ee51b77 ("perf/x86/intel/pt: Get rid of reverse lookup table for ToPA")
Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
---
 arch/x86/events/intel/pt.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index fd4670a6694e..96bd6aedeb37 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -1138,9 +1138,12 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf,
 		buf->intr_te = pt_topa_prev_entry(buf, buf->intr_te);
 	}
 
-	buf->stop_te->stop = 1;
-	buf->stop_te->intr = 1;
-	buf->intr_te->intr = 1;
+	if (buf->stop_te) {
+		buf->stop_te->stop = 1;
+		buf->stop_te->intr = 1;
+	}
+	if (buf->intr_te)
+		buf->intr_te->intr = 1;
 
 	return 0;
 }
-- 
2.46.2


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

end of thread, other threads:[~2024-10-25  6:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-01  8:27 [PATCH] perf/x86/intel/pt: Fix NULL pointer dereference in pt_buffer_reset_markers Qianqiang Liu
2024-10-24 11:16 ` Alexander Shishkin
2024-10-25  6:17   ` Qianqiang Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).