Messages in this thread Patch in this message | | | From | Taeung Song <> | Subject | [PATCH 3/3] perf ftrace: Handle NULL at write_tracing_file() | Date | Thu, 26 Jan 2017 18:35:39 +0900 |
| |
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
| |