[for-next][PATCH 13/13] tracing: Put back comma for empty fields in boot string parsing

From: Steven Rostedt
Date: Wed Nov 04 2015 - 10:33:13 EST


From: "Steven Rostedt (Red Hat)" <rostedt@xxxxxxxxxxx>

Both early_enable_events() and apply_trace_boot_options() parse a boot
string that may get parsed later on. They both use strsep() which converts a
comma into a nul character. To still allow the boot string to be parsed
again the same way, the nul character gets converted back to a comma after
the token is processed.

The problem is that these two functions check for an empty parameter (two
commas in a row ",,"), and continue the loop if the parameter is empty, but
fails to place the comma back. In this case, the second parsing will end at
this blank field, and not process fields afterward.

In most cases, users should not have an empty field, but if its going to be
checked, the code might as well be correct.

Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
kernel/trace/trace.c | 5 ++---
kernel/trace/trace_events.c | 16 ++++++++--------
2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 7fe7cc987dab..2198a630ef58 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3636,10 +3636,9 @@ static void __init apply_trace_boot_options(void)

if (!option)
break;
- if (!*option)
- continue;

- trace_set_options(&global_trace, option);
+ if (*option)
+ trace_set_options(&global_trace, option);

/* Put back the comma to allow this to be called again */
if (buf)
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 292bccf3e011..bee1e1530052 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -3042,16 +3042,16 @@ early_enable_events(struct trace_array *tr, bool disable_first)

if (!token)
break;
- if (!*token)
- continue;

- /* Restarting syscalls requires that we stop them first */
- if (disable_first)
- ftrace_set_clr_event(tr, token, 0);
+ if (*token) {
+ /* Restarting syscalls requires that we stop them first */
+ if (disable_first)
+ ftrace_set_clr_event(tr, token, 0);

- ret = ftrace_set_clr_event(tr, token, 1);
- if (ret)
- pr_warn("Failed to enable trace event: %s\n", token);
+ ret = ftrace_set_clr_event(tr, token, 1);
+ if (ret)
+ pr_warn("Failed to enable trace event: %s\n", token);
+ }

/* Put back the comma to allow this to be called again */
if (buf)
--
2.6.1


--
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/