io_prep_rw() relies on async_data being allocated in io_prep_rw_setup(). Be a bit more explicit and move the allocation earlier into io_prep_rw() and don't hide it in a call chain. Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> --- io_uring/rw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/io_uring/rw.c b/io_uring/rw.c index 22612a956e75..7efc2337c5a0 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -203,9 +203,6 @@ static int io_prep_rw_setup(struct io_kiocb *req, int ddir, bool do_import) { struct io_async_rw *rw; - if (io_rw_alloc_async(req)) - return -ENOMEM; - if (!do_import || io_do_buffer_select(req)) return 0; @@ -262,6 +259,9 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, u64 attr_type_mask; int ret; + if (io_rw_alloc_async(req)) + return -ENOMEM; + rw->kiocb.ki_pos = READ_ONCE(sqe->off); /* used for fixed read/write too - just read unconditionally */ req->buf_index = READ_ONCE(sqe->buf_index); -- 2.48.1