perf segfault in in ordered_events__free()

From: Song Liu
Date: Wed Jan 16 2019 - 13:58:04 EST


Hi,

We are debugging a segfault of perf in ordered_events__free().
Disassemble shows the segfault was caused by oe->buff == NULL
in the following line:

/*
* Current buffer might not have all the events allocated
* yet, we need to free only allocated ones ...
*/
list_del(&oe->buffer->list);

After poking around the code, I suspect it is caused by the following
condition in alloc_event():

} else if (oe->buffer) {
new = &oe->buffer->event[oe->buffer_idx];
if (++oe->buffer_idx == MAX_SAMPLE_BUFFER)
oe->buffer = NULL;

Does this theory make sense? If so, what would be the best fix?

Thanks in advance!
Song