From: David Howells Date: Mon, 22 May 2023 13:49:53 +0000 (+0100) Subject: splice: Check for zero count in vfs_splice_read() X-Git-Tag: v6.5-rc1~236^2~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=123856f0e83f457a3a24d15f561a1dd5f0d4b482;p=thirdparty%2Fkernel%2Flinux.git 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 Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner cc: Jens Axboe cc: Al Viro 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 --- diff --git a/fs/splice.c b/fs/splice.c index d815a69f65899..fe3309ffeb26c 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);