diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2012-07-11 09:35:08 +0300 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2012-07-11 19:56:26 -0400 |
commit | 93574fcc5b50cc7b8834698acb2ce947e5b6a5dc (patch) | |
tree | f40191d94dfc121737e1acb3463874f8dc702ba7 /kernel/trace | |
parent | c3b7cdf180090d2686239a75bb0ae408108ed749 (diff) | |
download | kernel_goldelico_gta04-93574fcc5b50cc7b8834698acb2ce947e5b6a5dc.zip kernel_goldelico_gta04-93574fcc5b50cc7b8834698acb2ce947e5b6a5dc.tar.gz kernel_goldelico_gta04-93574fcc5b50cc7b8834698acb2ce947e5b6a5dc.tar.bz2 |
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: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 814ff30..a120f98 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -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); } |