[PATCH v3 2/3] tracing: clear parser->idx if parser gets nothing

changbin.du
2018-01-16T09:12:01Z

From: Changbin Du <changbin.du@intel.com>

If only spaces was got in that cycle, we should clear parser->idx to make
trace_parser_loaded() return false.

Signed-off-by: Changbin Du <changbin.du@intel.com>
---
kernel/trace/trace.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 144d08e..b44926e 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -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 */
--
2.7.4