Skip to content

Commit

Permalink
ring-buffer: check for less than two in size allocation
Browse files Browse the repository at this point in the history
The ring buffer must have at least two pages allocated for the
reader page swap to work.

The page count check will miss the case of a zero size passed in.
Even though a zero size ring buffer would probably fail an allocation,
making the min size check for less than two instead of equal to one makes
the code a bit more robust.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Jun 17, 2009
1 parent 0dcd4d6 commit 5f78abe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/trace/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ struct ring_buffer *__ring_buffer_alloc(unsigned long size, unsigned flags,
buffer->reader_lock_key = key;

/* need at least two pages */
if (buffer->pages == 1)
buffer->pages++;
if (buffer->pages < 2)
buffer->pages = 2;

/*
* In case of non-hotplug cpu, if the ring-buffer is allocated
Expand Down

0 comments on commit 5f78abe

Please sign in to comment.