summaryrefslogtreecommitdiffstats
path: root/fs/splice.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2023-05-22 14:49:53 +0100
committerJens Axboe <axboe@kernel.dk>2023-05-24 08:42:16 -0600
commit123856f0e83f457a3a24d15f561a1dd5f0d4b482 (patch)
treea1b3b179663e314dba52bc63a023632ba1348c3d /fs/splice.c
parent6a3f30b8bdb23842aff5eea65b6a7693c49f5506 (diff)
downloadlinux-123856f0e83f457a3a24d15f561a1dd5f0d4b482.tar.gz
linux-123856f0e83f457a3a24d15f561a1dd5f0d4b482.tar.bz2
linux-123856f0e83f457a3a24d15f561a1dd5f0d4b482.zip
splice: Check for zero count in vfs_splice_read()
Make vfs_splice_read() return immediately if the length is 0. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Christian Brauner <brauner@kernel.org> cc: Jens Axboe <axboe@kernel.dk> cc: Al Viro <viro@zeniv.linux.org.uk> cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org Link: https://lore.kernel.org/r/20230522135018.2742245-7-dhowells@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/splice.c')
-rw-r--r--fs/splice.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/splice.c b/fs/splice.c
index d815a69f6589..fe3309ffeb26 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -891,6 +891,8 @@ long vfs_splice_read(struct file *in, loff_t *ppos,
if (unlikely(!(in->f_mode & FMODE_READ)))
return -EBADF;
+ if (!len)
+ return 0;
/* Don't try to read more the pipe has space for. */
p_space = pipe->max_usage - pipe_occupancy(pipe->head, pipe->tail);