Commit c46e22a8 authored by Al Viro's avatar Al Viro Committed by Jiri Slaby

fix memory leaks in tracing_buffers_splice_read()

commit 1ae2293d upstream.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent 32505f21
......@@ -5179,11 +5179,6 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
}
#endif
if (splice_grow_spd(pipe, &spd)) {
ret = -ENOMEM;
goto out;
}
if (*ppos & (PAGE_SIZE - 1)) {
ret = -EINVAL;
goto out;
......@@ -5197,6 +5192,11 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
len &= PAGE_MASK;
}
if (splice_grow_spd(pipe, &spd)) {
ret = -ENOMEM;
goto out;
}
again:
trace_access_lock(iter->cpu_file);
entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file);
......@@ -5252,21 +5252,22 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
if (!spd.nr_pages) {
if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK)) {
ret = -EAGAIN;
goto out;
goto out_shrink;
}
mutex_unlock(&trace_types_lock);
ret = iter->trace->wait_pipe(iter);
mutex_lock(&trace_types_lock);
if (ret)
goto out;
goto out_shrink;
if (signal_pending(current)) {
ret = -EINTR;
goto out;
goto out_shrink;
}
goto again;
}
ret = splice_to_pipe(pipe, &spd);
out_shrink:
splice_shrink_spd(&spd);
out:
mutex_unlock(&trace_types_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment