diff options
author | Jens Axboe <axboe@kernel.dk> | 2024-10-27 16:08:31 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-11-02 22:45:30 +0100 |
commit | b54a14041ee6444692d95ff38c8b3d1af682aa17 (patch) | |
tree | 658c5839cb2eb6dd19429c5e4911ea9cd727d664 /io_uring/rw.c | |
parent | io_uring/rsrc: unify file and buffer resource tables (diff) | |
download | linux-b54a14041ee6444692d95ff38c8b3d1af682aa17.tar.xz linux-b54a14041ee6444692d95ff38c8b3d1af682aa17.zip |
io_uring/rsrc: add io_rsrc_node_lookup() helper
There are lots of spots open-coding this functionality, add a generic
helper that does the node lookup in a speculation safe way.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/rw.c')
-rw-r--r-- | io_uring/rw.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/io_uring/rw.c b/io_uring/rw.c index 28fff18ebb19..30448f343c7f 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -332,17 +332,15 @@ static int io_prep_rw_fixed(struct io_kiocb *req, const struct io_uring_sqe *sqe struct io_ring_ctx *ctx = req->ctx; struct io_rsrc_node *node; struct io_async_rw *io; - u16 index; int ret; ret = io_prep_rw(req, sqe, ddir, false); if (unlikely(ret)) return ret; - if (unlikely(req->buf_index >= ctx->buf_table.nr)) + node = io_rsrc_node_lookup(&ctx->buf_table, req->buf_index); + if (!node) return -EFAULT; - index = array_index_nospec(req->buf_index, ctx->buf_table.nr); - node = ctx->buf_table.nodes[index]; io_req_assign_rsrc_node(req, node); io = req->async_data; |