aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorAlexander Z Lam <azl@google.com>2013-07-18 14:18:44 -0400
committerSteven Rostedt <rostedt@goodmis.org>2013-07-18 21:31:30 -0400
commitf77d09a384676bde6445413949d9d2c508ff3e62 (patch)
tree2b3bf03ac95453bdff4d03f20db79f46a647dea6 /kernel/trace/trace.c
parent609e85a70bcd0eedf4ec60639dbcfb1ab011e054 (diff)
tracing: Miscellaneous fixes for trace_array ref counting
Some error paths did not handle ref counting properly, and some trace files need ref counting. Link: http://lkml.kernel.org/r/1374171524-11948-1-git-send-email-azl@google.com Cc: stable@vger.kernel.org # 3.10 Cc: Vaibhav Nagarnaik <vnagarnaik@google.com> Cc: David Sharp <dhsharp@google.com> Cc: Alexander Z Lam <lambchop468@gmail.com> Signed-off-by: Alexander Z Lam <azl@google.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 7c3da7bca05b..7d9ceab42564 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3008,7 +3008,6 @@ static int tracing_release(struct inode *inode, struct file *file)
3008 3008
3009 iter = m->private; 3009 iter = m->private;
3010 tr = iter->tr; 3010 tr = iter->tr;
3011 trace_array_put(tr);
3012 3011
3013 mutex_lock(&trace_types_lock); 3012 mutex_lock(&trace_types_lock);
3014 3013
@@ -3023,6 +3022,9 @@ static int tracing_release(struct inode *inode, struct file *file)
3023 if (!iter->snapshot) 3022 if (!iter->snapshot)
3024 /* reenable tracing if it was previously enabled */ 3023 /* reenable tracing if it was previously enabled */
3025 tracing_start_tr(tr); 3024 tracing_start_tr(tr);
3025
3026 __trace_array_put(tr);
3027
3026 mutex_unlock(&trace_types_lock); 3028 mutex_unlock(&trace_types_lock);
3027 3029
3028 mutex_destroy(&iter->mutex); 3030 mutex_destroy(&iter->mutex);
@@ -3447,6 +3449,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
3447static int tracing_trace_options_open(struct inode *inode, struct file *file) 3449static int tracing_trace_options_open(struct inode *inode, struct file *file)
3448{ 3450{
3449 struct trace_array *tr = inode->i_private; 3451 struct trace_array *tr = inode->i_private;
3452 int ret;
3450 3453
3451 if (tracing_disabled) 3454 if (tracing_disabled)
3452 return -ENODEV; 3455 return -ENODEV;
@@ -3454,7 +3457,11 @@ static int tracing_trace_options_open(struct inode *inode, struct file *file)
3454 if (trace_array_get(tr) < 0) 3457 if (trace_array_get(tr) < 0)
3455 return -ENODEV; 3458 return -ENODEV;
3456 3459
3457 return single_open(file, tracing_trace_options_show, inode->i_private); 3460 ret = single_open(file, tracing_trace_options_show, inode->i_private);
3461 if (ret < 0)
3462 trace_array_put(tr);
3463
3464 return ret;
3458} 3465}
3459 3466
3460static const struct file_operations tracing_iter_fops = { 3467static const struct file_operations tracing_iter_fops = {
@@ -3958,6 +3965,7 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp)
3958 iter = kzalloc(sizeof(*iter), GFP_KERNEL); 3965 iter = kzalloc(sizeof(*iter), GFP_KERNEL);
3959 if (!iter) { 3966 if (!iter) {
3960 ret = -ENOMEM; 3967 ret = -ENOMEM;
3968 __trace_array_put(tr);
3961 goto out; 3969 goto out;
3962 } 3970 }
3963 3971
@@ -4704,21 +4712,24 @@ static int tracing_snapshot_open(struct inode *inode, struct file *file)
4704 ret = PTR_ERR(iter); 4712 ret = PTR_ERR(iter);
4705 } else { 4713 } else {
4706 /* Writes still need the seq_file to hold the private data */ 4714 /* Writes still need the seq_file to hold the private data */
4715 ret = -ENOMEM;
4707 m = kzalloc(sizeof(*m), GFP_KERNEL); 4716 m = kzalloc(sizeof(*m), GFP_KERNEL);
4708 if (!m) 4717 if (!m)
4709 return -ENOMEM; 4718 goto out;
4710 iter = kzalloc(sizeof(*iter), GFP_KERNEL); 4719 iter = kzalloc(sizeof(*iter), GFP_KERNEL);
4711 if (!iter) { 4720 if (!iter) {
4712 kfree(m); 4721 kfree(m);
4713 return -ENOMEM; 4722 goto out;
4714 } 4723 }
4724 ret = 0;
4725
4715 iter->tr = tr; 4726 iter->tr = tr;
4716 iter->trace_buffer = &tc->tr->max_buffer; 4727 iter->trace_buffer = &tc->tr->max_buffer;
4717 iter->cpu_file = tc->cpu; 4728 iter->cpu_file = tc->cpu;
4718 m->private = iter; 4729 m->private = iter;
4719 file->private_data = m; 4730 file->private_data = m;
4720 } 4731 }
4721 4732out:
4722 if (ret < 0) 4733 if (ret < 0)
4723 trace_array_put(tr); 4734 trace_array_put(tr);
4724 4735
@@ -5328,9 +5339,10 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
5328} 5339}
5329 5340
5330static const struct file_operations tracing_stats_fops = { 5341static const struct file_operations tracing_stats_fops = {
5331 .open = tracing_open_generic, 5342 .open = tracing_open_generic_tc,
5332 .read = tracing_stats_read, 5343 .read = tracing_stats_read,
5333 .llseek = generic_file_llseek, 5344 .llseek = generic_file_llseek,
5345 .release = tracing_release_generic_tc,
5334}; 5346};
5335 5347
5336#ifdef CONFIG_DYNAMIC_FTRACE 5348#ifdef CONFIG_DYNAMIC_FTRACE