Commit 26c8fae2 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] oprofile per-cpu buffer overrun

From: Philippe Elie <phil.el@wanadoo.fr>

In a ring buffer controlled by a read and write positions we can't use
buffer_size but only buffer_size - 1 entry, the last free entry act as a
guard to avoid write pos overrun.  This bug was hidden because the writer,
oprofile_add_sample(), request one more entry than really needed.
parent 2c8aa408
......@@ -86,9 +86,9 @@ static unsigned long nr_available_slots(struct oprofile_cpu_buffer const * b)
unsigned long tail = b->tail_pos;
if (tail > head)
return tail - head;
return (tail - head) - 1;
return tail + (b->buffer_size - head);
return tail + (b->buffer_size - head) - 1;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment