summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Chancellor <nathan@kernel.org>2022-02-07 19:24:11 +0300
committerJens Axboe <axboe@kernel.dk>2022-03-10 16:32:49 +0300
commitf0a4e62bb5343b3b7163bc851cfb4bebfefcc4e7 (patch)
treeaa101625b03fc6ddde55ca6c567df18faf563ce5
parent8bb649ee1da321ec3a1bbec048a425c5ea18ea21 (diff)
downloadlinux-f0a4e62bb5343b3b7163bc851cfb4bebfefcc4e7.tar.xz
io_uring: Fix use of uninitialized ret in io_eventfd_register()
Clang warns: fs/io_uring.c:9396:9: warning: variable 'ret' is uninitialized when used here [-Wuninitialized] return ret; ^~~ fs/io_uring.c:9373:13: note: initialize the variable 'ret' to silence this warning int fd, ret; ^ = 0 1 warning generated. Just return 0 directly and reduce the scope of ret to the if statement, as that is the only place that it is used, which is how the function was before the fixes commit. Fixes: 1a75fac9a0f9 ("io_uring: avoid ring quiesce while registering/unregistering eventfd") Link: https://github.com/ClangBuiltLinux/linux/issues/1579 Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Link: https://lore.kernel.org/r/20220207162410.1013466-1-nathan@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--fs/io_uring.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 49bcc5fc688d..1dce3f6e7031 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -9378,7 +9378,7 @@ static int io_eventfd_register(struct io_ring_ctx *ctx, void __user *arg,
{
struct io_ev_fd *ev_fd;
__s32 __user *fds = arg;
- int fd, ret;
+ int fd;
ev_fd = rcu_dereference_protected(ctx->io_ev_fd,
lockdep_is_held(&ctx->uring_lock));
@@ -9394,14 +9394,14 @@ static int io_eventfd_register(struct io_ring_ctx *ctx, void __user *arg,
ev_fd->cq_ev_fd = eventfd_ctx_fdget(fd);
if (IS_ERR(ev_fd->cq_ev_fd)) {
- ret = PTR_ERR(ev_fd->cq_ev_fd);
+ int ret = PTR_ERR(ev_fd->cq_ev_fd);
kfree(ev_fd);
return ret;
}
ev_fd->eventfd_async = eventfd_async;
rcu_assign_pointer(ctx->io_ev_fd, ev_fd);
- return ret;
+ return 0;
}
static void io_eventfd_put(struct rcu_head *rcu)