提交 93574fcc 编写于 作者: D Dan Carpenter 提交者: Steven Rostedt

tracing: Check for allocation failure in __tracing_open()

Clean up and return -ENOMEM on if the kzalloc() fails.

This also prevents a potential crash, as the pointer that failed to
allocate would be later used.

Link: http://lkml.kernel.org/r/20120711063507.GF11812@elgon.mountain

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
上级 c3b7cdf1
...@@ -2390,6 +2390,9 @@ __tracing_open(struct inode *inode, struct file *file) ...@@ -2390,6 +2390,9 @@ __tracing_open(struct inode *inode, struct file *file)
iter->buffer_iter = kzalloc(sizeof(*iter->buffer_iter) * num_possible_cpus(), iter->buffer_iter = kzalloc(sizeof(*iter->buffer_iter) * num_possible_cpus(),
GFP_KERNEL); GFP_KERNEL);
if (!iter->buffer_iter)
goto release;
/* /*
* We make a copy of the current tracer to avoid concurrent * We make a copy of the current tracer to avoid concurrent
* changes on it while we are reading. * changes on it while we are reading.
...@@ -2451,6 +2454,7 @@ __tracing_open(struct inode *inode, struct file *file) ...@@ -2451,6 +2454,7 @@ __tracing_open(struct inode *inode, struct file *file)
mutex_unlock(&trace_types_lock); mutex_unlock(&trace_types_lock);
kfree(iter->trace); kfree(iter->trace);
kfree(iter->buffer_iter); kfree(iter->buffer_iter);
release:
seq_release_private(inode, file); seq_release_private(inode, file);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册