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>
This commit is contained in:
Родитель
e30f53aad2
Коммит
07906da788
|
@ -5494,7 +5494,7 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
|
||||||
};
|
};
|
||||||
struct buffer_ref *ref;
|
struct buffer_ref *ref;
|
||||||
int entries, size, i;
|
int entries, size, i;
|
||||||
ssize_t ret;
|
ssize_t ret = 0;
|
||||||
|
|
||||||
mutex_lock(&trace_types_lock);
|
mutex_lock(&trace_types_lock);
|
||||||
|
|
||||||
|
@ -5532,13 +5532,16 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
ref = kzalloc(sizeof(*ref), GFP_KERNEL);
|
ref = kzalloc(sizeof(*ref), GFP_KERNEL);
|
||||||
if (!ref)
|
if (!ref) {
|
||||||
|
ret = -ENOMEM;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ref->ref = 1;
|
ref->ref = 1;
|
||||||
ref->buffer = iter->trace_buffer->buffer;
|
ref->buffer = iter->trace_buffer->buffer;
|
||||||
ref->page = ring_buffer_alloc_read_page(ref->buffer, iter->cpu_file);
|
ref->page = ring_buffer_alloc_read_page(ref->buffer, iter->cpu_file);
|
||||||
if (!ref->page) {
|
if (!ref->page) {
|
||||||
|
ret = -ENOMEM;
|
||||||
kfree(ref);
|
kfree(ref);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5576,6 +5579,9 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
|
||||||
|
|
||||||
/* did we read anything? */
|
/* did we read anything? */
|
||||||
if (!spd.nr_pages) {
|
if (!spd.nr_pages) {
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
|
||||||
if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK)) {
|
if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK)) {
|
||||||
ret = -EAGAIN;
|
ret = -EAGAIN;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче