aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2009-06-14 22:56:42 -0400
committerSteven Rostedt <rostedt@goodmis.org>2009-06-15 11:37:12 -0400
commit215368e8e59023d6a0abdda896923018d74fdf7f (patch)
tree904bef6f1f3895843c5fbf288fd487713b78ed2c /kernel/trace/trace.c
parent78be6914cb5c6d648617c51bb99bf81f28471d89 (diff)
tracing: fix a typo in tracing_cpumask_write()
It's tracing_cpumask_new that should be kfree()ed. This causes tracing_cpumask to be freed due to the typo: # echo z > tracing_cpumask bash: echo: write error: Invalid argument And subsequent reads/writes to tracing_cpuamsk will access this already-freed tracing_cpumask, thus may lead to crash. [ Impact: fix leak and crash when writing invalid val to tracing_cpumask ] Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> LKML-Reference: <4A35B86A.7070608@cn.fujitsu.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8acd9b81a5d7..7355a38e18be 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2191,11 +2191,12 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
2191 if (!alloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL)) 2191 if (!alloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL))
2192 return -ENOMEM; 2192 return -ENOMEM;
2193 2193
2194 mutex_lock(&tracing_cpumask_update_lock);
2195 err = cpumask_parse_user(ubuf, count, tracing_cpumask_new); 2194 err = cpumask_parse_user(ubuf, count, tracing_cpumask_new);
2196 if (err) 2195 if (err)
2197 goto err_unlock; 2196 goto err_unlock;
2198 2197
2198 mutex_lock(&tracing_cpumask_update_lock);
2199
2199 local_irq_disable(); 2200 local_irq_disable();
2200 __raw_spin_lock(&ftrace_max_lock); 2201 __raw_spin_lock(&ftrace_max_lock);
2201 for_each_tracing_cpu(cpu) { 2202 for_each_tracing_cpu(cpu) {
@@ -2223,8 +2224,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
2223 return count; 2224 return count;
2224 2225
2225err_unlock: 2226err_unlock:
2226 mutex_unlock(&tracing_cpumask_update_lock); 2227 free_cpumask_var(tracing_cpumask_new);
2227 free_cpumask_var(tracing_cpumask);
2228 2228
2229 return err; 2229 return err;
2230} 2230}