summaryrefslogtreecommitdiff
path: root/io_uring/register.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2025-01-16 02:53:26 +0000
committerJens Axboe <axboe@kernel.dk>2025-01-21 07:07:17 -0700
commitbb2d76344bc80933a462aa84581d1258e0dc758b (patch)
treeb1a35a8f49a7215025c69f47d8d66d2d8efc24d2 /io_uring/register.c
parent5719e2823565a304a2afb752d4792c622a693e22 (diff)
io_uring: clean up io_uring_register_get_file()
Make it always reference the returned file. It's safer, especially with unregistrations happening under it. And it makes the api cleaner with no conditional clean ups by the caller. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/0d0b13a63e8edd6b5d360fc821dcdb035cb6b7e0.1736995897.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/register.c')
-rw-r--r--io_uring/register.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/io_uring/register.c b/io_uring/register.c
index 05025047d1da..0db181437ae3 100644
--- a/io_uring/register.c
+++ b/io_uring/register.c
@@ -853,6 +853,8 @@ struct file *io_uring_register_get_file(unsigned int fd, bool registered)
return ERR_PTR(-EINVAL);
fd = array_index_nospec(fd, IO_RINGFD_REG_MAX);
file = tctx->registered_rings[fd];
+ if (file)
+ get_file(file);
} else {
file = fget(fd);
}
@@ -919,7 +921,7 @@ SYSCALL_DEFINE4(io_uring_register, unsigned int, fd, unsigned int, opcode,
trace_io_uring_register(ctx, opcode, ctx->file_table.data.nr,
ctx->buf_table.nr, ret);
mutex_unlock(&ctx->uring_lock);
- if (!use_registered_ring)
- fput(file);
+
+ fput(file);
return ret;
}