[tip:perf/core] tracing: Add checks if tr->buffer is NULL in tracing_reset{_online_cpus}

From: tip-bot for Hiraku Toyooka
Date: Thu Jan 24 2013 - 14:39:39 EST


Commit-ID: a54164114b96b4693b42cdb553260eec41ea4393
Gitweb: http://git.kernel.org/tip/a54164114b96b4693b42cdb553260eec41ea4393
Author: Hiraku Toyooka <hiraku.toyooka.gu@xxxxxxxxxxx>
AuthorDate: Wed, 19 Dec 2012 16:02:34 +0900
Committer: Steven Rostedt <rostedt@xxxxxxxxxxx>
CommitDate: Mon, 21 Jan 2013 13:22:32 -0500

tracing: Add checks if tr->buffer is NULL in tracing_reset{_online_cpus}

max_tr->buffer could be NULL in the tracing_reset{_online_cpus}. In this
case, a NULL pointer dereference happens, so we should return immediately
from these functions.

Note, the current code does not call tracing_reset*() with max_tr when
its buffer is NULL, but future code will. This patch is needed to prevent
the future code from crashing.

Link: http://lkml.kernel.org/r/20121219070234.31200.93863.stgit@liselsia

Signed-off-by: Hiraku Toyooka <hiraku.toyooka.gu@xxxxxxxxxxx>
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
kernel/trace/trace.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index f8b7c62..72b171b 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -922,6 +922,9 @@ void tracing_reset(struct trace_array *tr, int cpu)
{
struct ring_buffer *buffer = tr->buffer;

+ if (!buffer)
+ return;
+
ring_buffer_record_disable(buffer);

/* Make sure all commits have finished */
@@ -936,6 +939,9 @@ void tracing_reset_online_cpus(struct trace_array *tr)
struct ring_buffer *buffer = tr->buffer;
int cpu;

+ if (!buffer)
+ return;
+
ring_buffer_record_disable(buffer);

/* Make sure all commits have finished */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/