LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] Add pointer check
@ 2021-09-18 3:01 cgel.zte
2021-09-20 10:42 ` Alexander Shishkin
0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2021-09-18 3:01 UTC (permalink / raw)
To: peterz
Cc: mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung,
tglx, bp, x86, hpa, linux-perf-users, linux-kernel, Yang Guang
From: Yang Guang <yang.guang5@zte.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@zte.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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Add pointer check
2021-09-18 3:01 [PATCH] Add pointer check cgel.zte
@ 2021-09-20 10:42 ` Alexander Shishkin
0 siblings, 0 replies; 2+ messages in thread
From: Alexander Shishkin @ 2021-09-20 10:42 UTC (permalink / raw)
To: cgel.zte, peterz
Cc: mingo, acme, mark.rutland, jolsa, namhyung, tglx, bp, x86, hpa,
linux-perf-users, linux-kernel, Yang Guang, alexander.shishkin
cgel.zte@gmail.com writes:
> From: Yang Guang <yang.guang5@zte.com.cn>
>
> The buf->stop_te pointer may be NULL.
[...]
> --- 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) {
It really can't be NULL at this point.
Regards,
--
Alex
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-20 10:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-18 3:01 [PATCH] Add pointer check cgel.zte
2021-09-20 10:42 ` Alexander Shishkin
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).