Skip to content

Commit

Permalink
fix memory leaks in tracing_buffers_splice_read()
Browse files Browse the repository at this point in the history
Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro authored and rostedt committed Sep 25, 2016
1 parent 1245800 commit 1ae2293
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -5930,9 +5930,6 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
return -EBUSY;
#endif

if (splice_grow_spd(pipe, &spd))
return -ENOMEM;

if (*ppos & (PAGE_SIZE - 1))
return -EINVAL;

Expand All @@ -5942,6 +5939,9 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
len &= PAGE_MASK;
}

if (splice_grow_spd(pipe, &spd))
return -ENOMEM;

again:
trace_access_lock(iter->cpu_file);
entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file);
Expand Down Expand Up @@ -5999,19 +5999,21 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
/* did we read anything? */
if (!spd.nr_pages) {
if (ret)
return ret;
goto out;

ret = -EAGAIN;
if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK))
return -EAGAIN;
goto out;

ret = wait_on_pipe(iter, true);
if (ret)
return ret;
goto out;

goto again;
}

ret = splice_to_pipe(pipe, &spd);
out:
splice_shrink_spd(&spd);

return ret;
Expand Down

0 comments on commit 1ae2293

Please sign in to comment.