diff options
| author | Jens Axboe <axboe@kernel.dk> | 2024-10-27 09:08:31 -0600 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2024-11-02 15:45:30 -0600 |
| commit | b54a14041ee6444692d95ff38c8b3d1af682aa17 (patch) | |
| tree | 658c5839cb2eb6dd19429c5e4911ea9cd727d664 /io_uring/splice.c | |
| parent | 3597f2786b687a7f26361ce00a805ea0af41b65f (diff) | |
| download | linux-b54a14041ee6444692d95ff38c8b3d1af682aa17.tar.gz linux-b54a14041ee6444692d95ff38c8b3d1af682aa17.tar.bz2 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/splice.c')
| -rw-r--r-- | io_uring/splice.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/io_uring/splice.c b/io_uring/splice.c index aaaddb66e90a..deeb8bb18651 100644 --- a/io_uring/splice.c +++ b/io_uring/splice.c @@ -66,17 +66,13 @@ static struct file *io_splice_get_file(struct io_kiocb *req, return io_file_get_normal(req, sp->splice_fd_in); io_ring_submit_lock(ctx, issue_flags); - if (unlikely(sp->splice_fd_in >= ctx->file_table.data.nr)) - goto out; - sp->splice_fd_in = array_index_nospec(sp->splice_fd_in, ctx->file_table.data.nr); - node = ctx->file_table.data.nodes[sp->splice_fd_in]; + node = io_rsrc_node_lookup(&ctx->file_table.data, sp->splice_fd_in); if (node) { node->refs++; sp->rsrc_node = node; file = io_slot_file(node); req->flags |= REQ_F_NEED_CLEANUP; } -out: io_ring_submit_unlock(ctx, issue_flags); return file; } |
