Re: [PATCH] perf/x86/intel/pt: Fix NULL pointer dereference in pt_buffer_reset_markers

From: Alexander Shishkin
Date: Thu Oct 24 2024 - 07:16:19 EST


Qianqiang Liu <qianqiang.liu@xxxxxxx> writes:

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

Iirc, this has come up before, because static analyzers get the idea
that at that point ->stop_te and ->intr_te can be NULL, but in reality,
they can't. When the buffer is created, stop_pos and intr_pos are set to
-1, which will always force ->stop_te and ->intr_te to be set the first
time around.

So no, not a bug. It might deserve a comment explaining the above logic,
so that more versions of this patch don't get generated from static
analyzers' reports.

Regards,
--
Alex