[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1333653586-3379-2-git-send-email-mark.asselstine@windriver.com>
Date: Thu, 5 Apr 2012 15:19:44 -0400
From: Mark Asselstine <mark.asselstine@...driver.com>
To: <rostedt@...dmis.org>
CC: <linux-kernel@...r.kernel.org>, <mark.asselstine@...driver.com>
Subject: [PATCH 1/3] trace-cmd: add checks for invalid pointers to fix segfaults
Running 'trace-cmd report' after running latency tracers will cause a
segfault due to invalid pointers. Adding checks to ensure
pointers/lists are initialized before attempting to use them prevents
these segfaults.
Signed-off-by: Mark Asselstine <mark.asselstine@...driver.com>
---
trace-input.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/trace-input.c b/trace-input.c
index b6af1e6..5151c1e 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -695,7 +695,8 @@ static void __free_page(struct tracecmd_input *handle, struct page *page)
static void free_page(struct tracecmd_input *handle, int cpu)
{
- if (!handle->cpu_data[cpu].page)
+ if (!handle->cpu_data || cpu >= handle->cpus ||
+ !handle->cpu_data[cpu].page)
return;
__free_page(handle, handle->cpu_data[cpu].page);
@@ -746,8 +747,12 @@ void tracecmd_record_ref(struct record *record)
static void free_next(struct tracecmd_input *handle, int cpu)
{
- struct record *record = handle->cpu_data[cpu].next;
+ struct record *record;
+
+ if (!handle->cpu_data || cpu >= handle->cpus)
+ return;
+ record = handle->cpu_data[cpu].next;
if (!record)
return;
@@ -2337,7 +2342,8 @@ void tracecmd_close(struct tracecmd_input *handle)
/* The tracecmd_peek_data may have cached a record */
free_next(handle, cpu);
free_page(handle, cpu);
- if (!list_empty(&handle->cpu_data[cpu].pages))
+ if (handle->cpu_data &&
+ !list_empty(&handle->cpu_data[cpu].pages))
warning("pages still allocated on cpu %d%s",
cpu, show_records(&handle->cpu_data[cpu].pages));
}
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists