aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 0cd500bffd9b..3f2477713aca 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 = {
@@ -3537,14 +3544,14 @@ static const char readme_msg[] =
3537 "\n snapshot\t\t- Like 'trace' but shows the content of the static snapshot buffer\n" 3544 "\n snapshot\t\t- Like 'trace' but shows the content of the static snapshot buffer\n"
3538 "\t\t\t Read the contents for more information\n" 3545 "\t\t\t Read the contents for more information\n"
3539#endif 3546#endif
3540#ifdef CONFIG_STACKTRACE 3547#ifdef CONFIG_STACK_TRACER
3541 " stack_trace\t\t- Shows the max stack trace when active\n" 3548 " stack_trace\t\t- Shows the max stack trace when active\n"
3542 " stack_max_size\t- Shows current max stack size that was traced\n" 3549 " stack_max_size\t- Shows current max stack size that was traced\n"
3543 "\t\t\t Write into this file to reset the max size (trigger a new trace)\n" 3550 "\t\t\t Write into this file to reset the max size (trigger a new trace)\n"
3544#ifdef CONFIG_DYNAMIC_FTRACE 3551#ifdef CONFIG_DYNAMIC_FTRACE
3545 " stack_trace_filter\t- Like set_ftrace_filter but limits what stack_trace traces\n" 3552 " stack_trace_filter\t- Like set_ftrace_filter but limits what stack_trace traces\n"
3546#endif 3553#endif
3547#endif /* CONFIG_STACKTRACE */ 3554#endif /* CONFIG_STACK_TRACER */
3548; 3555;
3549 3556
3550static ssize_t 3557static ssize_t
@@ -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
@@ -4948,8 +4959,6 @@ static int tracing_buffers_open(struct inode *inode, struct file *filp)
4948 4959
4949 mutex_lock(&trace_types_lock); 4960 mutex_lock(&trace_types_lock);
4950 4961
4951 tr->ref++;
4952
4953 info->iter.tr = tr; 4962 info->iter.tr = tr;
4954 info->iter.cpu_file = tc->cpu; 4963 info->iter.cpu_file = tc->cpu;
4955 info->iter.trace = tr->current_trace; 4964 info->iter.trace = tr->current_trace;
@@ -5328,9 +5337,10 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
5328} 5337}
5329 5338
5330static const struct file_operations tracing_stats_fops = { 5339static const struct file_operations tracing_stats_fops = {
5331 .open = tracing_open_generic, 5340 .open = tracing_open_generic_tc,
5332 .read = tracing_stats_read, 5341 .read = tracing_stats_read,
5333 .llseek = generic_file_llseek, 5342 .llseek = generic_file_llseek,
5343 .release = tracing_release_generic_tc,
5334}; 5344};
5335 5345
5336#ifdef CONFIG_DYNAMIC_FTRACE 5346#ifdef CONFIG_DYNAMIC_FTRACE
@@ -5973,8 +5983,10 @@ static int new_instance_create(const char *name)
5973 goto out_free_tr; 5983 goto out_free_tr;
5974 5984
5975 ret = event_trace_add_tracer(tr->dir, tr); 5985 ret = event_trace_add_tracer(tr->dir, tr);
5976 if (ret) 5986 if (ret) {
5987 debugfs_remove_recursive(tr->dir);
5977 goto out_free_tr; 5988 goto out_free_tr;
5989 }
5978 5990
5979 init_tracer_debugfs(tr, tr->dir); 5991 init_tracer_debugfs(tr, tr->dir);
5980 5992