tracing: Clear parser->idx if only spaces are read
authorChangbin Du <changbin.du@intel.com>
Tue, 16 Jan 2018 09:02:29 +0000 (17:02 +0800)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Tue, 23 Jan 2018 20:57:28 +0000 (15:57 -0500)
If only spaces were read while parsing the next string, then parser->idx should be
cleared in order to make trace_parser_loaded() return false.

Link: http://lkml.kernel.org/r/1516093350-12045-3-git-send-email-changbin.du@intel.com
Acked-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Changbin Du <changbin.du@intel.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace.c

index c00a31d18f8a43d7e68a86065cd50e2985cae077..cb90435e63da44a9ef3007c4d3793b2fe91b4964 100644 (file)
@@ -1236,14 +1236,14 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
                        cnt--;
                }
 
+               parser->idx = 0;
+
                /* only spaces were written */
                if (isspace(ch) || !ch) {
                        *ppos += read;
                        ret = read;
                        goto out;
                }
-
-               parser->idx = 0;
        }
 
        /* read the non-space input */