tracing: check for allocation failure
Subsystems (2)
PATCH 1/1 tracing: check for allocation failure
Clean up and return -ENOMEM on if the kzalloc() fails.
Signed-off-by Dan Carpenter <[email protected]>
kernel/trace/trace.c +4 -0
@@ -2390,6 +2390,9 @@ __tracing_open(struct inode *inode, struct file *file) iter->buffer_iter =kzalloc (sizeof (*iter->buffer_iter) *num_possible_cpus (),GFP_KERNEL ); +if (!iter->buffer_iter) + goto release; +/* * We make a copy of the current tracer to avoid concurrent * changes on it while we are reading.
@@ -2451,6 +2454,7 @@ __tracing_open(struct inode *inode, struct file *file)mutex_unlock (&trace_types_lock);kfree (iter->trace);kfree (iter->buffer_iter); +release:seq_release_private (inode, file);return ERR_PTR (-ENOMEM ); }
[tip:perf/core] tracing: Check for allocation failure in __tracing_open()
Commit-ID: 93574fcc5b50cc7b8834698acb2ce947e5b6a5dc Gitweb: http://git.kernel.org/tip/93574fcc5b50cc7b8834698acb2ce947e5b6a5dc Author: Dan Carpenter <[email protected]> AuthorDate: Wed, 11 Jul 2012 09:35:08 +0300 Committer: Steven Rostedt <[email protected]> CommitDate: Wed, 11 Jul 2012 19:56:26 -0400
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.
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Signed-off-by Dan Carpenter <[email protected]>
Signed-off-by Steven Rostedt <[email protected]>
--- kernel/trace/trace.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/trace/trace.c +4 -0
@@ -2390,6 +2390,9 @@ __tracing_open(struct inode *inode, struct file *file) iter->buffer_iter =kzalloc (sizeof (*iter->buffer_iter) *num_possible_cpus (),GFP_KERNEL ); +if (!iter->buffer_iter) + goto release; +/* * We make a copy of the current tracer to avoid concurrent * changes on it while we are reading.
@@ -2451,6 +2454,7 @@ __tracing_open(struct inode *inode, struct file *file)mutex_unlock (&trace_types_lock);kfree (iter->trace);kfree (iter->buffer_iter); +release:seq_release_private (inode, file);return ERR_PTR (-ENOMEM ); }