lkml.org 
[lkml]   [2017]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/3] perf ftrace: Handle NULL at write_tracing_file()
Date
If a value for tracing file is NULL,
segment fault error can occur using strlen().
Of course, currently the function don't be given NULL value.
But write_tracing_file() can be generally used.
So add the if statement.

Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
tools/perf/builtin-ftrace.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 8df5416..0754dee 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -54,8 +54,12 @@ static int write_tracing_file(const char *name, const char *val)
{
char *file;
int fd, ret = -1;
- ssize_t size = strlen(val);
+ ssize_t size;

+ if (val == NULL)
+ return -1;
+
+ size = strlen(val);
file = get_tracing_file(name);
if (!file) {
pr_debug("cannot get tracing file: %s\n", name);
--
2.7.4
\
 
 \ /
  Last update: 2017-01-26 10:37    [W:2.808 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site