mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-13 14:24:11 +08:00
io_uring: use io_file_from_index in __io_sync_cancel
Use io_file_from_index instead of open coding it. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20230620113235.920399-7-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
8487f083c6
commit
60a666f097
@ -216,13 +216,10 @@ static int __io_sync_cancel(struct io_uring_task *tctx,
|
|||||||
/* fixed must be grabbed every time since we drop the uring_lock */
|
/* fixed must be grabbed every time since we drop the uring_lock */
|
||||||
if ((cd->flags & IORING_ASYNC_CANCEL_FD) &&
|
if ((cd->flags & IORING_ASYNC_CANCEL_FD) &&
|
||||||
(cd->flags & IORING_ASYNC_CANCEL_FD_FIXED)) {
|
(cd->flags & IORING_ASYNC_CANCEL_FD_FIXED)) {
|
||||||
unsigned long file_ptr;
|
|
||||||
|
|
||||||
if (unlikely(fd >= ctx->nr_user_files))
|
if (unlikely(fd >= ctx->nr_user_files))
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
fd = array_index_nospec(fd, ctx->nr_user_files);
|
fd = array_index_nospec(fd, ctx->nr_user_files);
|
||||||
file_ptr = io_fixed_file_slot(&ctx->file_table, fd)->file_ptr;
|
cd->file = io_file_from_index(&ctx->file_table, fd);
|
||||||
cd->file = (struct file *) (file_ptr & FFS_MASK);
|
|
||||||
if (!cd->file)
|
if (!cd->file)
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user