aboutsummaryrefslogtreecommitdiffstats
path: root/io_uring/rsrc.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-06-20 13:32:35 +0200
committerJens Axboe <axboe@kernel.dk>2023-06-20 09:36:22 -0600
commit4bfb0c9af832a182a54e549123a634e0070c8d4f (patch)
tree8c683eb5980341ac8682d0e6bea2df1fc59fcc97 /io_uring/rsrc.c
parentf432c8c8c12b84c5465b1ffddb6feb7d6b19c1ca (diff)
downloadlinux-4bfb0c9af832a182a54e549123a634e0070c8d4f.tar.gz
io_uring: add helpers to decode the fixed file file_ptr
Remove all the open coded magic on slot->file_ptr by introducing two helpers that return the file pointer and the flags instead. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20230620113235.920399-9-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/rsrc.c')
-rw-r--r--io_uring/rsrc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index d46f72a5ef732..a2dce7ef3a787 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -354,7 +354,6 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
__s32 __user *fds = u64_to_user_ptr(up->data);
struct io_rsrc_data *data = ctx->file_data;
struct io_fixed_file *file_slot;
- struct file *file;
int fd, i, err = 0;
unsigned int done;
@@ -382,15 +381,16 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
file_slot = io_fixed_file_slot(&ctx->file_table, i);
if (file_slot->file_ptr) {
- file = (struct file *)(file_slot->file_ptr & FFS_MASK);
- err = io_queue_rsrc_removal(data, i, file);
+ err = io_queue_rsrc_removal(data, i,
+ io_slot_file(file_slot));
if (err)
break;
file_slot->file_ptr = 0;
io_file_bitmap_clear(&ctx->file_table, i);
}
if (fd != -1) {
- file = fget(fd);
+ struct file *file = fget(fd);
+
if (!file) {
err = -EBADF;
break;