]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
tracing: protect ring_buffer_expanded with trace_types_lock
authorSteven Rostedt <srostedt@redhat.com>
Thu, 12 Mar 2009 15:33:20 +0000 (11:33 -0400)
committerSteven Rostedt <srostedt@redhat.com>
Fri, 13 Mar 2009 01:14:58 +0000 (21:14 -0400)
Impact: prevent races with ring_buffer_expanded

This patch places the expanding of the tracing buffer under the
protection of the trace_types_lock mutex. It is highly unlikely
that there would be any contention, but better safe than sorry.

Reported-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
kernel/trace/trace.c

index c61ee85c50bbea3fac9bd63f240f3faeb0550b9e..04ab8243a13d1d6ebcb3fb2a6a610b6281e200f9 100644 (file)
@@ -2391,8 +2391,10 @@ int tracing_update_buffers(void)
 {
        int ret = 0;
 
+       mutex_lock(&trace_types_lock);
        if (!ring_buffer_expanded)
                ret = tracing_resize_ring_buffer(trace_buf_size);
+       mutex_unlock(&trace_types_lock);
 
        return ret;
 }
@@ -2412,6 +2414,8 @@ static int tracing_set_tracer(const char *buf)
        struct tracer *t;
        int ret = 0;
 
+       mutex_lock(&trace_types_lock);
+
        if (!ring_buffer_expanded) {
                ret = tracing_resize_ring_buffer(trace_buf_size);
                if (ret < 0)
@@ -2419,7 +2423,6 @@ static int tracing_set_tracer(const char *buf)
                ret = 0;
        }
 
-       mutex_lock(&trace_types_lock);
        for (t = trace_types; t; t = t->next) {
                if (strcmp(t->name, buf) == 0)
                        break;