aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2014-04-29 16:07:28 -0400
committerSteven Rostedt <rostedt@goodmis.org>2014-04-29 16:07:28 -0400
commitf4874261049e3abdd481359d82cafa5068369ebd (patch)
treeee81269a6086634c7ae04c18eba24fb717528590
parent8d1b065d47ff1424b1aef7a6aa605b467694c120 (diff)
tracing: Break out of tracing_wait_pipe() before wait_pipe() is called
When reading from trace_pipe, if tracing is off but nothing was read it should block. If something is read and tracing is off, then EOF is returned. If tracing is on and there's nothing to read, it will block. But because the check of whether tracing is off and something was read is done after the block on the pipe, it is hit or miss if the EOF is returned or not leading to inconsistent behavior. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--kernel/trace/trace.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index cb41e98cc64b..e058c6091e45 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4237,15 +4237,6 @@ static int tracing_wait_pipe(struct file *filp)
4237 return -EAGAIN; 4237 return -EAGAIN;
4238 } 4238 }
4239 4239
4240 mutex_unlock(&iter->mutex);
4241
4242 iter->trace->wait_pipe(iter);
4243
4244 mutex_lock(&iter->mutex);
4245
4246 if (signal_pending(current))
4247 return -EINTR;
4248
4249 /* 4240 /*
4250 * We block until we read something and tracing is disabled. 4241 * We block until we read something and tracing is disabled.
4251 * We still block if tracing is disabled, but we have never 4242 * We still block if tracing is disabled, but we have never
@@ -4257,6 +4248,15 @@ static int tracing_wait_pipe(struct file *filp)
4257 */ 4248 */
4258 if (!tracing_is_on() && iter->pos) 4249 if (!tracing_is_on() && iter->pos)
4259 break; 4250 break;
4251
4252 mutex_unlock(&iter->mutex);
4253
4254 iter->trace->wait_pipe(iter);
4255
4256 mutex_lock(&iter->mutex);
4257
4258 if (signal_pending(current))
4259 return -EINTR;
4260 } 4260 }
4261 4261
4262 return 1; 4262 return 1;