[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210918030131.236378-1-yang.guang5@zte.com.cn>
Date: Sat, 18 Sep 2021 03:01:31 +0000
From: cgel.zte@...il.com
To: peterz@...radead.org
Cc: mingo@...hat.com, acme@...nel.org, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, jolsa@...hat.com,
namhyung@...nel.org, tglx@...utronix.de, bp@...en8.de,
x86@...nel.org, hpa@...or.com, linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org, Yang Guang <yang.guang5@....com.cn>
Subject: [PATCH] Add pointer check
From: Yang Guang <yang.guang5@....com.cn>
The buf->stop_te pointer may be NULL.
Accessing buf->stop_te->stop buf->stop_te->intr might occer segmentation
fault. Same as buf->intr_te.
Signed-off-by: Yang Guang <yang.guang5@....com.cn>
---
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 7f406c14715f..ec1c644fc83f 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -1118,9 +1118,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.25.1
Powered by blists - more mailing lists