Commit d6d3523c authored by Geyslan G. Bem's avatar Geyslan G. Bem Committed by Steven Rostedt

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.comSigned-off-by: default avatarGeyslan G. Bem <geyslan@gmail.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 2e86421d
...@@ -1062,6 +1062,9 @@ static int subsystem_open(struct inode *inode, struct file *filp) ...@@ -1062,6 +1062,9 @@ static int subsystem_open(struct inode *inode, struct file *filp)
struct trace_array *tr; struct trace_array *tr;
int ret; int ret;
if (tracing_is_disabled())
return -ENODEV;
/* Make sure the system still exists */ /* Make sure the system still exists */
mutex_lock(&trace_types_lock); mutex_lock(&trace_types_lock);
mutex_lock(&event_mutex); mutex_lock(&event_mutex);
...@@ -1108,6 +1111,9 @@ static int system_tr_open(struct inode *inode, struct file *filp) ...@@ -1108,6 +1111,9 @@ static int system_tr_open(struct inode *inode, struct file *filp)
struct trace_array *tr = inode->i_private; struct trace_array *tr = inode->i_private;
int ret; int ret;
if (tracing_is_disabled())
return -ENODEV;
if (trace_array_get(tr) < 0) if (trace_array_get(tr) < 0)
return -ENODEV; return -ENODEV;
...@@ -1124,11 +1130,12 @@ static int system_tr_open(struct inode *inode, struct file *filp) ...@@ -1124,11 +1130,12 @@ static int system_tr_open(struct inode *inode, struct file *filp)
if (ret < 0) { if (ret < 0) {
trace_array_put(tr); trace_array_put(tr);
kfree(dir); kfree(dir);
return ret;
} }
filp->private_data = dir; filp->private_data = dir;
return ret; return 0;
} }
static int subsystem_release(struct inode *inode, struct file *file) static int subsystem_release(struct inode *inode, struct file *file)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment