From: Jens Axboe Date: Thu, 25 Aug 2022 16:19:08 +0000 (-0600) Subject: io_uring: fix issue with io_write() not always undoing sb_start_write() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=295219ab7d6250e56cba480cb8b46302401d9cce;p=linux.git io_uring: fix issue with io_write() not always undoing sb_start_write() commit e053aaf4da56cbf0afb33a0fda4a62188e2c0637 upstream. This is actually an older issue, but we never used to hit the -EAGAIN path before having done sb_start_write(). Make sure that we always call kiocb_end_write() if we need to retry the write, so that we keep the calls to sb_start_write() etc balanced. Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/io_uring.c b/fs/io_uring.c index 89f24b54fe5e8..2680e9756b1d4 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3720,7 +3720,12 @@ done: copy_iov: iov_iter_restore(iter, state); ret = io_setup_async_rw(req, iovec, inline_vecs, iter, false); - return ret ?: -EAGAIN; + if (!ret) { + if (kiocb->ki_flags & IOCB_WRITE) + kiocb_end_write(req); + return -EAGAIN; + } + return ret; } out_free: /* it's reportedly faster than delegating the null check to kfree() */