summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorGeyslan G. Bem <geyslan@gmail.com>2013-11-06 16:02:51 -0300
committerSteven Rostedt <rostedt@goodmis.org>2013-11-06 15:26:54 -0500
commitd6d3523caab75196560c85aae80cb8f4a8e380ea (patch)
treec051e62d5e1579a530ed2966d1ee38f5c7a8dce8 /kernel
parent2e86421debc2cf4d1513c9b73fcd34c5ce431ae3 (diff)
downloadop-kernel-dev-d6d3523caab75196560c85aae80cb8f4a8e380ea.zip
op-kernel-dev-d6d3523caab75196560c85aae80cb8f4a8e380ea.tar.gz
tracing: Do not assign filp->private_data to freed memory
In system_tr_open(), the filp->private_data can be assigned the 'dir' variable even if it was freed. This is on the error path, and is harmless because the error return code will prevent filp->private_data from being used. But for correctness, we should not assign it to a recently freed variable, as that can cause static tools to give false warnings. Also have both subsystem_open() and system_tr_open() return -ENODEV if tracing has been disabled. Link: http://lkml.kernel.org/r/1383764571-7318-1-git-send-email-geyslan@gmail.com Signed-off-by: Geyslan G. Bem <geyslan@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/trace_events.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 043f833..f919a2e 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1062,6 +1062,9 @@ static int subsystem_open(struct inode *inode, struct file *filp)
struct trace_array *tr;
int ret;
+ if (tracing_is_disabled())
+ return -ENODEV;
+
/* Make sure the system still exists */
mutex_lock(&trace_types_lock);
mutex_lock(&event_mutex);
@@ -1108,6 +1111,9 @@ static int system_tr_open(struct inode *inode, struct file *filp)
struct trace_array *tr = inode->i_private;
int ret;
+ if (tracing_is_disabled())
+ return -ENODEV;
+
if (trace_array_get(tr) < 0)
return -ENODEV;
@@ -1124,11 +1130,12 @@ static int system_tr_open(struct inode *inode, struct file *filp)
if (ret < 0) {
trace_array_put(tr);
kfree(dir);
+ return ret;
}
filp->private_data = dir;
- return ret;
+ return 0;
}
static int subsystem_release(struct inode *inode, struct file *file)
OpenPOWER on IntegriCloud