[PATCH 5.19] io_uring: fix provided buffer import

Dylan Yudaken posted 1 patch 3 years, 9 months ago
fs/io_uring.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[PATCH 5.19] io_uring: fix provided buffer import
Posted by Dylan Yudaken 3 years, 9 months ago
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: 2be2eb02e2f5 ("io_uring: ensure reads re-import for selected buffers")
Signed-off-by: Dylan Yudaken <dylany@fb.com>
---
 fs/io_uring.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 5ff2cdb425bc..73ae92a62c2c 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -4314,6 +4314,9 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags)
 		if (unlikely(ret < 0))
 			return ret;
 	} else {
+		rw = req->async_data;
+		s = &rw->s;
+
 		/*
 		 * Safe and required to re-import if we're using provided
 		 * buffers, as we dropped the selected one before retry.
@@ -4324,8 +4327,6 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags)
 				return ret;
 		}
 
-		rw = req->async_data;
-		s = &rw->s;
 		/*
 		 * We come here from an earlier attempt, restore our state to
 		 * match in case it doesn't. It's cheap enough that we don't
-- 
2.30.2
Re: [PATCH 5.19] io_uring: fix provided buffer import
Posted by Jens Axboe 3 years, 9 months ago
On Thu, 30 Jun 2022 06:20:06 -0700, Dylan Yudaken wrote:
> 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.
> 
> 
> [...]

Applied, thanks!

[1/1] io_uring: fix provided buffer import
      commit: ee10e6851a687c58f516dc924034cb62c7a01e14

Best regards,
-- 
Jens Axboe