Skip to content

Commit c968742

Browse files
isilenceaxboe
authored andcommitted
io_uring: fix zero len do_splice()
do_splice() doesn't expect len to be 0. Just always return 0 in this case as splice(2) does. Fixes: 7d67af2 ("io_uring: add splice(2) support") Reported-by: Jann Horn <[email protected]> Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 63ff822 commit c968742

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fs/io_uring.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,16 +2767,19 @@ static int io_splice(struct io_kiocb *req, bool force_nonblock)
27672767
struct file *out = sp->file_out;
27682768
unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED;
27692769
loff_t *poff_in, *poff_out;
2770-
long ret;
2770+
long ret = 0;
27712771

27722772
if (force_nonblock)
27732773
return -EAGAIN;
27742774

27752775
poff_in = (sp->off_in == -1) ? NULL : &sp->off_in;
27762776
poff_out = (sp->off_out == -1) ? NULL : &sp->off_out;
2777-
ret = do_splice(in, poff_in, out, poff_out, sp->len, flags);
2778-
if (force_nonblock && ret == -EAGAIN)
2779-
return -EAGAIN;
2777+
2778+
if (sp->len) {
2779+
ret = do_splice(in, poff_in, out, poff_out, sp->len, flags);
2780+
if (force_nonblock && ret == -EAGAIN)
2781+
return -EAGAIN;
2782+
}
27802783

27812784
io_put_file(req, in, (sp->flags & SPLICE_F_FD_IN_FIXED));
27822785
req->flags &= ~REQ_F_NEED_CLEANUP;

0 commit comments

Comments
 (0)