Skip to content

Commit 1ae2293

Browse files
Al Virorostedt
authored andcommitted
fix memory leaks in tracing_buffers_splice_read()
Cc: [email protected] Signed-off-by: Al Viro <[email protected]>
1 parent 1245800 commit 1ae2293

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

kernel/trace/trace.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5930,9 +5930,6 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
59305930
return -EBUSY;
59315931
#endif
59325932

5933-
if (splice_grow_spd(pipe, &spd))
5934-
return -ENOMEM;
5935-
59365933
if (*ppos & (PAGE_SIZE - 1))
59375934
return -EINVAL;
59385935

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

5942+
if (splice_grow_spd(pipe, &spd))
5943+
return -ENOMEM;
5944+
59455945
again:
59465946
trace_access_lock(iter->cpu_file);
59475947
entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file);
@@ -5999,19 +5999,21 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
59995999
/* did we read anything? */
60006000
if (!spd.nr_pages) {
60016001
if (ret)
6002-
return ret;
6002+
goto out;
60036003

6004+
ret = -EAGAIN;
60046005
if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK))
6005-
return -EAGAIN;
6006+
goto out;
60066007

60076008
ret = wait_on_pipe(iter, true);
60086009
if (ret)
6009-
return ret;
6010+
goto out;
60106011

60116012
goto again;
60126013
}
60136014

60146015
ret = splice_to_pipe(pipe, &spd);
6016+
out:
60156017
splice_shrink_spd(&spd);
60166018

60176019
return ret;

0 commit comments

Comments
 (0)