aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorRabin Vincent <rabin@rab.in>2014-11-06 16:26:07 -0500
committerSteven Rostedt <rostedt@goodmis.org>2014-11-10 16:47:31 -0500
commit07906da78810dce5fd35b9449358c9208c693dca (patch)
tree045b776e6ac22d844050cb6a155095732d9f40d4 /kernel
parente30f53aad2202b5526c40c36d8eeac8bf290bde5 (diff)
tracing: Do not risk busy looping in buffer splice
If the read loop in trace_buffers_splice_read() keeps failing due to memory allocation failures without reading even a single page then this function will keep busy looping. Remove the risk for that by exiting the function if memory allocation failures are seen. Link: http://lkml.kernel.org/r/1415309167-2373-2-git-send-email-rabin@rab.in Signed-off-by: Rabin Vincent <rabin@rab.in> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/trace.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 15209335888d..92f4a6cee172 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -5494,7 +5494,7 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
5494 }; 5494 };
5495 struct buffer_ref *ref; 5495 struct buffer_ref *ref;
5496 int entries, size, i; 5496 int entries, size, i;
5497 ssize_t ret; 5497 ssize_t ret = 0;
5498 5498
5499 mutex_lock(&trace_types_lock); 5499 mutex_lock(&trace_types_lock);
5500 5500
@@ -5532,13 +5532,16 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
5532 int r; 5532 int r;
5533 5533
5534 ref = kzalloc(sizeof(*ref), GFP_KERNEL); 5534 ref = kzalloc(sizeof(*ref), GFP_KERNEL);
5535 if (!ref) 5535 if (!ref) {
5536 ret = -ENOMEM;
5536 break; 5537 break;
5538 }
5537 5539
5538 ref->ref = 1; 5540 ref->ref = 1;
5539 ref->buffer = iter->trace_buffer->buffer; 5541 ref->buffer = iter->trace_buffer->buffer;
5540 ref->page = ring_buffer_alloc_read_page(ref->buffer, iter->cpu_file); 5542 ref->page = ring_buffer_alloc_read_page(ref->buffer, iter->cpu_file);
5541 if (!ref->page) { 5543 if (!ref->page) {
5544 ret = -ENOMEM;
5542 kfree(ref); 5545 kfree(ref);
5543 break; 5546 break;
5544 } 5547 }
@@ -5576,6 +5579,9 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
5576 5579
5577 /* did we read anything? */ 5580 /* did we read anything? */
5578 if (!spd.nr_pages) { 5581 if (!spd.nr_pages) {
5582 if (ret)
5583 goto out;
5584
5579 if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK)) { 5585 if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK)) {
5580 ret = -EAGAIN; 5586 ret = -EAGAIN;
5581 goto out; 5587 goto out;