]> Pileus Git - ~andy/linux/blobdiff - kernel/trace/ftrace.c
Merge branch 'fixes-for-linus' of git://git.monstr.eu/linux-2.6-microblaze
[~andy/linux] / kernel / trace / ftrace.c
index c71e91bf7372499efc0dec2a6ede46f9aa492d0a..3724756e41ca9771d311101a38d2f408d416ef6a 100644 (file)
@@ -225,7 +225,11 @@ static void ftrace_update_pid_func(void)
        if (ftrace_trace_function == ftrace_stub)
                return;
 
+#ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST
        func = ftrace_trace_function;
+#else
+       func = __ftrace_trace_function;
+#endif
 
        if (ftrace_pid_trace) {
                set_ftrace_pid_function(func);
@@ -1520,7 +1524,7 @@ static int t_show(struct seq_file *m, void *v)
        return 0;
 }
 
-static struct seq_operations show_ftrace_seq_ops = {
+static const struct seq_operations show_ftrace_seq_ops = {
        .start = t_start,
        .next = t_next,
        .stop = t_stop,
@@ -1621,8 +1625,10 @@ ftrace_regex_open(struct inode *inode, struct file *file, int enable)
                if (!ret) {
                        struct seq_file *m = file->private_data;
                        m->private = iter;
-               } else
+               } else {
+                       trace_parser_put(&iter->parser);
                        kfree(iter);
+               }
        } else
                file->private_data = iter;
        mutex_unlock(&ftrace_regex_lock);
@@ -2202,7 +2208,7 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
        struct trace_parser *parser;
        ssize_t ret, read;
 
-       if (!cnt || cnt < 0)
+       if (!cnt)
                return 0;
 
        mutex_lock(&ftrace_regex_lock);
@@ -2216,7 +2222,7 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
        parser = &iter->parser;
        read = trace_get_user(parser, ubuf, cnt, ppos);
 
-       if (trace_parser_loaded(parser) &&
+       if (read >= 0 && trace_parser_loaded(parser) &&
            !trace_parser_cont(parser)) {
                ret = ftrace_process_regex(parser->buffer,
                                           parser->idx, enable);
@@ -2459,7 +2465,7 @@ static int g_show(struct seq_file *m, void *v)
        return 0;
 }
 
-static struct seq_operations ftrace_graph_seq_ops = {
+static const struct seq_operations ftrace_graph_seq_ops = {
        .start = g_start,
        .next = g_next,
        .stop = g_stop,
@@ -2552,8 +2558,7 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
                   size_t cnt, loff_t *ppos)
 {
        struct trace_parser parser;
-       size_t read = 0;
-       ssize_t ret;
+       ssize_t read, ret;
 
        if (!cnt || cnt < 0)
                return 0;
@@ -2562,29 +2567,31 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
 
        if (ftrace_graph_count >= FTRACE_GRAPH_MAX_FUNCS) {
                ret = -EBUSY;
-               goto out;
+               goto out_unlock;
        }
 
        if (trace_parser_get_init(&parser, FTRACE_BUFF_MAX)) {
                ret = -ENOMEM;
-               goto out;
+               goto out_unlock;
        }
 
        read = trace_get_user(&parser, ubuf, cnt, ppos);
 
-       if (trace_parser_loaded((&parser))) {
+       if (read >= 0 && trace_parser_loaded((&parser))) {
                parser.buffer[parser.idx] = 0;
 
                /* we allow only one expression at a time */
                ret = ftrace_set_func(ftrace_graph_funcs, &ftrace_graph_count,
                                        parser.buffer);
                if (ret)
-                       goto out;
+                       goto out_free;
        }
 
        ret = read;
- out:
+
+out_free:
        trace_parser_put(&parser);
+out_unlock:
        mutex_unlock(&graph_lock);
 
        return ret;
@@ -3015,7 +3022,7 @@ int unregister_ftrace_function(struct ftrace_ops *ops)
 
 int
 ftrace_enable_sysctl(struct ctl_table *table, int write,
-                    struct file *file, void __user *buffer, size_t *lenp,
+                    void __user *buffer, size_t *lenp,
                     loff_t *ppos)
 {
        int ret;
@@ -3025,7 +3032,7 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
 
        mutex_lock(&ftrace_lock);
 
-       ret  = proc_dointvec(table, write, file, buffer, lenp, ppos);
+       ret  = proc_dointvec(table, write, buffer, lenp, ppos);
 
        if (ret || !write || (last_ftrace_enabled == !!ftrace_enabled))
                goto out;