Skip to content

Commit 09007af

Browse files
Dylan Yudakenaxboe
authored andcommitted
io_uring: fix provided buffer import
io_import_iovec uses the s pointer, but this was changed immediately after the iovec was re-imported and so it was imported into the wrong place. Change the ordering. Fixes: 2be2eb0 ("io_uring: ensure reads re-import for selected buffers") Signed-off-by: Dylan Yudaken <dylany@fb.com> Link: https://lore.kernel.org/r/20220630132006.2825668-1-dylany@fb.com [axboe: ensure we don't half-import as well] Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 29c1ac2 commit 09007af

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fs/io_uring.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4318,18 +4318,19 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags)
43184318
if (unlikely(ret < 0))
43194319
return ret;
43204320
} else {
4321+
rw = req->async_data;
4322+
s = &rw->s;
4323+
43214324
/*
43224325
* Safe and required to re-import if we're using provided
43234326
* buffers, as we dropped the selected one before retry.
43244327
*/
4325-
if (req->flags & REQ_F_BUFFER_SELECT) {
4328+
if (io_do_buffer_select(req)) {
43264329
ret = io_import_iovec(READ, req, &iovec, s, issue_flags);
43274330
if (unlikely(ret < 0))
43284331
return ret;
43294332
}
43304333

4331-
rw = req->async_data;
4332-
s = &rw->s;
43334334
/*
43344335
* We come here from an earlier attempt, restore our state to
43354336
* match in case it doesn't. It's cheap enough that we don't

0 commit comments

Comments
 (0)