[PATCH] Add pointer check

From: cgel . zte
Date: Fri Sep 17 2021 - 23:01:42 EST


From: Yang Guang <yang.guang5@xxxxxxxxxx>

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@xxxxxxxxxx>
---
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