Преглед на файлове

tracing: fix mmiotrace resizing crash

Pekka reported a crash when resizing the mmiotrace tracer (if only
mmiotrace is enabled).

This happens because in that case we do not allocate the max buffer,
but we try to use it.

Make ring_buffer_resize() idempotent against NULL buffers.

Reported-by: Pekka Paalanen <pq@iki.fi>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Ingo Molnar преди 16 години
родител
ревизия
ee51a1de7e
променени са 1 файла, в които са добавени 6 реда и са изтрити 0 реда
  1. 6 0
      kernel/trace/ring_buffer.c

+ 6 - 0
kernel/trace/ring_buffer.c

@@ -538,6 +538,12 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
 	LIST_HEAD(pages);
 	LIST_HEAD(pages);
 	int i, cpu;
 	int i, cpu;
 
 
+	/*
+	 * Always succeed at resizing a non-existent buffer:
+	 */
+	if (!buffer)
+		return size;
+
 	size = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
 	size = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
 	size *= BUF_PAGE_SIZE;
 	size *= BUF_PAGE_SIZE;
 	buffer_size = buffer->pages * BUF_PAGE_SIZE;
 	buffer_size = buffer->pages * BUF_PAGE_SIZE;