aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2013-05-09 18:20:37 -0400
committerSteven Rostedt <rostedt@goodmis.org>2013-05-09 20:15:30 -0400
commit5ae0bf5972b66d35e5674e1b7d855b1e111a68ae (patch)
tree6383ef4d7fd63d6da285f3908c6f3c14028715a0
parentda511bf33e47ea1f33f4b672f7da166d2a1b8a91 (diff)
ftrace: Fix locking in register_ftrace_function_probe()
The iteration of the ftrace function list and the call to ftrace_match_record() need to be protected by the ftrace_lock. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--kernel/trace/ftrace.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index cacf0856191e..f104c45cbcc1 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3017,14 +3017,16 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
3017 hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash); 3017 hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
3018 if (!hash) { 3018 if (!hash) {
3019 count = -ENOMEM; 3019 count = -ENOMEM;
3020 goto out_unlock; 3020 goto out;
3021 } 3021 }
3022 3022
3023 if (unlikely(ftrace_disabled)) { 3023 if (unlikely(ftrace_disabled)) {
3024 count = -ENODEV; 3024 count = -ENODEV;
3025 goto out_unlock; 3025 goto out;
3026 } 3026 }
3027 3027
3028 mutex_lock(&ftrace_lock);
3029
3028 do_for_each_ftrace_rec(pg, rec) { 3030 do_for_each_ftrace_rec(pg, rec) {
3029 3031
3030 if (!ftrace_match_record(rec, NULL, search, len, type)) 3032 if (!ftrace_match_record(rec, NULL, search, len, type))
@@ -3070,15 +3072,15 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
3070 3072
3071 } while_for_each_ftrace_rec(); 3073 } while_for_each_ftrace_rec();
3072 3074
3073 mutex_lock(&ftrace_lock);
3074 ret = ftrace_hash_move(&trace_probe_ops, 1, orig_hash, hash); 3075 ret = ftrace_hash_move(&trace_probe_ops, 1, orig_hash, hash);
3075 if (ret < 0) 3076 if (ret < 0)
3076 count = ret; 3077 count = ret;
3077 3078
3078 __enable_ftrace_function_probe(); 3079 __enable_ftrace_function_probe();
3079 mutex_unlock(&ftrace_lock);
3080 3080
3081 out_unlock: 3081 out_unlock:
3082 mutex_unlock(&ftrace_lock);
3083 out:
3082 mutex_unlock(&trace_probe_ops.regex_lock); 3084 mutex_unlock(&trace_probe_ops.regex_lock);
3083 free_ftrace_hash(hash); 3085 free_ftrace_hash(hash);
3084 3086