aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/ftrace.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/ftrace.c')
-rw-r--r--kernel/trace/ftrace.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index c71e91bf7372..46592feab5a6 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1520,7 +1520,7 @@ static int t_show(struct seq_file *m, void *v)
1520 return 0; 1520 return 0;
1521} 1521}
1522 1522
1523static struct seq_operations show_ftrace_seq_ops = { 1523static const struct seq_operations show_ftrace_seq_ops = {
1524 .start = t_start, 1524 .start = t_start,
1525 .next = t_next, 1525 .next = t_next,
1526 .stop = t_stop, 1526 .stop = t_stop,
@@ -1621,8 +1621,10 @@ ftrace_regex_open(struct inode *inode, struct file *file, int enable)
1621 if (!ret) { 1621 if (!ret) {
1622 struct seq_file *m = file->private_data; 1622 struct seq_file *m = file->private_data;
1623 m->private = iter; 1623 m->private = iter;
1624 } else 1624 } else {
1625 trace_parser_put(&iter->parser);
1625 kfree(iter); 1626 kfree(iter);
1627 }
1626 } else 1628 } else
1627 file->private_data = iter; 1629 file->private_data = iter;
1628 mutex_unlock(&ftrace_regex_lock); 1630 mutex_unlock(&ftrace_regex_lock);
@@ -2202,7 +2204,7 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
2202 struct trace_parser *parser; 2204 struct trace_parser *parser;
2203 ssize_t ret, read; 2205 ssize_t ret, read;
2204 2206
2205 if (!cnt || cnt < 0) 2207 if (!cnt)
2206 return 0; 2208 return 0;
2207 2209
2208 mutex_lock(&ftrace_regex_lock); 2210 mutex_lock(&ftrace_regex_lock);
@@ -2216,7 +2218,7 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
2216 parser = &iter->parser; 2218 parser = &iter->parser;
2217 read = trace_get_user(parser, ubuf, cnt, ppos); 2219 read = trace_get_user(parser, ubuf, cnt, ppos);
2218 2220
2219 if (trace_parser_loaded(parser) && 2221 if (read >= 0 && trace_parser_loaded(parser) &&
2220 !trace_parser_cont(parser)) { 2222 !trace_parser_cont(parser)) {
2221 ret = ftrace_process_regex(parser->buffer, 2223 ret = ftrace_process_regex(parser->buffer,
2222 parser->idx, enable); 2224 parser->idx, enable);
@@ -2459,7 +2461,7 @@ static int g_show(struct seq_file *m, void *v)
2459 return 0; 2461 return 0;
2460} 2462}
2461 2463
2462static struct seq_operations ftrace_graph_seq_ops = { 2464static const struct seq_operations ftrace_graph_seq_ops = {
2463 .start = g_start, 2465 .start = g_start,
2464 .next = g_next, 2466 .next = g_next,
2465 .stop = g_stop, 2467 .stop = g_stop,
@@ -2552,8 +2554,7 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
2552 size_t cnt, loff_t *ppos) 2554 size_t cnt, loff_t *ppos)
2553{ 2555{
2554 struct trace_parser parser; 2556 struct trace_parser parser;
2555 size_t read = 0; 2557 ssize_t read, ret;
2556 ssize_t ret;
2557 2558
2558 if (!cnt || cnt < 0) 2559 if (!cnt || cnt < 0)
2559 return 0; 2560 return 0;
@@ -2562,29 +2563,31 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
2562 2563
2563 if (ftrace_graph_count >= FTRACE_GRAPH_MAX_FUNCS) { 2564 if (ftrace_graph_count >= FTRACE_GRAPH_MAX_FUNCS) {
2564 ret = -EBUSY; 2565 ret = -EBUSY;
2565 goto out; 2566 goto out_unlock;
2566 } 2567 }
2567 2568
2568 if (trace_parser_get_init(&parser, FTRACE_BUFF_MAX)) { 2569 if (trace_parser_get_init(&parser, FTRACE_BUFF_MAX)) {
2569 ret = -ENOMEM; 2570 ret = -ENOMEM;
2570 goto out; 2571 goto out_unlock;
2571 } 2572 }
2572 2573
2573 read = trace_get_user(&parser, ubuf, cnt, ppos); 2574 read = trace_get_user(&parser, ubuf, cnt, ppos);
2574 2575
2575 if (trace_parser_loaded((&parser))) { 2576 if (read >= 0 && trace_parser_loaded((&parser))) {
2576 parser.buffer[parser.idx] = 0; 2577 parser.buffer[parser.idx] = 0;
2577 2578
2578 /* we allow only one expression at a time */ 2579 /* we allow only one expression at a time */
2579 ret = ftrace_set_func(ftrace_graph_funcs, &ftrace_graph_count, 2580 ret = ftrace_set_func(ftrace_graph_funcs, &ftrace_graph_count,
2580 parser.buffer); 2581 parser.buffer);
2581 if (ret) 2582 if (ret)
2582 goto out; 2583 goto out_free;
2583 } 2584 }
2584 2585
2585 ret = read; 2586 ret = read;
2586 out: 2587
2588out_free:
2587 trace_parser_put(&parser); 2589 trace_parser_put(&parser);
2590out_unlock:
2588 mutex_unlock(&graph_lock); 2591 mutex_unlock(&graph_lock);
2589 2592
2590 return ret; 2593 return ret;
@@ -3015,7 +3018,7 @@ int unregister_ftrace_function(struct ftrace_ops *ops)
3015 3018
3016int 3019int
3017ftrace_enable_sysctl(struct ctl_table *table, int write, 3020ftrace_enable_sysctl(struct ctl_table *table, int write,
3018 struct file *file, void __user *buffer, size_t *lenp, 3021 void __user *buffer, size_t *lenp,
3019 loff_t *ppos) 3022 loff_t *ppos)
3020{ 3023{
3021 int ret; 3024 int ret;
@@ -3025,7 +3028,7 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
3025 3028
3026 mutex_lock(&ftrace_lock); 3029 mutex_lock(&ftrace_lock);
3027 3030
3028 ret = proc_dointvec(table, write, file, buffer, lenp, ppos); 3031 ret = proc_dointvec(table, write, buffer, lenp, ppos);
3029 3032
3030 if (ret || !write || (last_ftrace_enabled == !!ftrace_enabled)) 3033 if (ret || !write || (last_ftrace_enabled == !!ftrace_enabled))
3031 goto out; 3034 goto out;