Message ID | 20181202180832.GR8125@magnolia (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,1/2] splice: don't read more than available pipe space | expand |
diff --git a/fs/splice.c b/fs/splice.c index 3553f1956508..4bd9d9590199 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -949,7 +949,10 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd, size_t read_len; loff_t pos = sd->pos, prev_pos = pos; - ret = do_splice_to(in, &pos, pipe, len, flags); + /* Don't try to read more the pipe has space for. */ + read_len = min_t(size_t, len, + (pipe->buffers - pipe->nrbufs) << PAGE_SHIFT); + ret = do_splice_to(in, &pos, pipe, read_len, flags); if (unlikely(ret <= 0)) goto out_release;