]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
tracing/rb: Init the CPU mask on allocation
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Wed, 7 Dec 2016 13:31:33 +0000 (14:31 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 7 Dec 2016 13:36:21 +0000 (14:36 +0100)
Before commit b32614c03413 ("tracing/rb: Convert to hotplug state machine")
the allocated cpumask was initialized to the mask of online or possible
CPUs. After the CPU hotplug changes the buffer initialization moved to
trace_rb_cpu_prepare() but the cpumask is allocated with alloc_cpumask()
and therefor has random content. As a consequence the cpu buffers are not
initialized and a later access dereferences a NULL pointer.

Use zalloc_cpumask() instead so trace_rb_cpu_prepare() initializes the
buffers properly.

Fixes: b32614c03413 ("tracing/rb: Convert to hotplug state machine")
Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: rostedt@goodmis.org
Link: http://lkml.kernel.org/r/20161207133133.hzkcqfllxcdi3joz@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/trace/ring_buffer.c

index a7a055f167c7c79a8845ae9d0e0489a2c0c73b6e..89a2611a16357b87bd4fb3ea35c63f1d9c05744b 100644 (file)
@@ -1297,7 +1297,7 @@ struct ring_buffer *__ring_buffer_alloc(unsigned long size, unsigned flags,
        if (!buffer)
                return NULL;
 
-       if (!alloc_cpumask_var(&buffer->cpumask, GFP_KERNEL))
+       if (!zalloc_cpumask_var(&buffer->cpumask, GFP_KERNEL))
                goto fail_free_buffer;
 
        nr_pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE);