blob: 0fff1cd2827c816ffba5f8f4399ec53947317036 [file] [log] [blame]
From d0c4e140d4d2bb517517aca54c221836e9b72483 Mon Sep 17 00:00:00 2001
From: Luis Claudio R. Goncalves <lclaudio@uudg.org>
Date: Fri, 3 Jul 2009 13:16:33 -0500
Subject: [PATCH] trace: function profiler band-aid
commit dea2d9a0550f1a8da36a380567b61de9d9a83208 in tip.
Kernel Panic when stressing ftrace function_profiler
https://bugzilla.redhat.com/show_bug.cgi?id=500156
This patch does not fix the whole issue but removes a few probable spots
where the panic could originate from.
[root@void ~]# while true
> do echo "starting new test..."
> ./function_profiler.sh sleep 2 > /dev/null
> dmesg -c
> ./function_profiler.sh ls -la > /dev/null
> dmesg -c;
> done
starting new test...
starting new test...
...
Kernel panic - not syncing: Fatal exception
Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 1e6640f..a6d0ebe 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -392,7 +392,8 @@ static int function_stat_show(struct seq_file *m, void *v)
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
seq_printf(m, " ");
avg = rec->time;
- do_div(avg, rec->counter);
+ if (rec->counter)
+ do_div(avg, rec->counter);
mutex_lock(&mutex);
trace_seq_init(&s);
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index b1342c5..c2eef67 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -608,7 +608,7 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
int ret, len;
int i;
- sprintf(msecs_str, "%lu", (unsigned long) duration);
+ snprintf(msecs_str, sizeof(msecs_str), "%lu", (unsigned long) duration);
/* Print msecs */
ret = trace_seq_printf(s, "%s", msecs_str);
--
1.7.1.1