[PATCH 1/4] [PATCH 1/4] tracing: Fix strstrip usage in set_ftrace_pid
From: Steven Rostedt
Date: Thu Nov 19 2009 - 12:12:04 EST
From: Javier Martinez Canillas <martinez.javier@xxxxxxxxx>
The code in writing to set_ftrace_pid crops off whitespace before and
after the passed in string. But the usage of strstrip is incorrect,
and does not do the intended job.
# echo ' 3431 ' > /debug/tracing/set_ftrace_pid
-bash: echo: write error: Invalid argument
With this fix, the above line now succeeds.
Signed-off-by: Javier Martinez Canillas <martinez.javier@xxxxxxxxx>
LKML-Reference: <1256965563.4278.7.camel@laptop>
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
kernel/trace/ftrace.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 7f9b51e..b29ff29 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2987,6 +2987,7 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf,
{
char buf[64];
long val;
+ char *bufstr;
int ret;
if (cnt >= sizeof(buf))
@@ -3001,11 +3002,11 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf,
* Allow "echo > set_ftrace_pid" or "echo -n '' > set_ftrace_pid"
* to clean the filter quietly.
*/
- strstrip(buf);
- if (strlen(buf) == 0)
+ bufstr = strstrip(buf);
+ if (strlen(bufstr) == 0)
return 1;
- ret = strict_strtol(buf, 10, &val);
+ ret = strict_strtol(bufstr, 10, &val);
if (ret < 0)
return ret;
--
1.6.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/