All of lore.kernel.org
 help / color / mirror / Atom feed
From: Usama Arif <usama.arif@bytedance.com>
To: Nathan Chancellor <nathan@kernel.org>,
	Jens Axboe <axboe@kernel.dk>,
	Pavel Begunkov <asml.silence@gmail.com>,
	trix@redhat.com, Nick Desaulniers <ndesaulniers@google.com>
Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev
Subject: Re: [External] [PATCH] io_uring: Fix use of uninitialized ret in io_eventfd_register()
Date: Tue, 8 Feb 2022 13:37:22 +0000	[thread overview]
Message-ID: <2af2d61f-bd3d-5288-7bd2-4768ebe266d7@bytedance.com> (raw)
In-Reply-To: <20220207162410.1013466-1-nathan@kernel.org>



On 07/02/2022 16:24, Nathan Chancellor wrote:
> 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>
> ---
>   fs/io_uring.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>

Thanks for pointing this out. Just for some background in earlier 
revisions of the patch for "io_uring: avoid ring quiesce while 
registering/unregistering eventfd" the error return part was being 
handled differently, but ended up looking similar to before in the final 
revision that got merged, but i forgot to change this part back. Would 
it be possible to fold the below diff into the patch as well Jens?
Thanks and sorry for missing this!

Regards,
Usama

> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 5479f0607430..7ef04bb66da1 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -9370,7 +9370,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));
> @@ -9386,14 +9386,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)
> 
> base-commit: 88a0394bc27de2dd8a8715970f289c5627052532
> 

  parent reply	other threads:[~2022-02-08 13:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-07 16:24 [PATCH] io_uring: Fix use of uninitialized ret in io_eventfd_register() Nathan Chancellor
2022-02-07 19:32 ` Nick Desaulniers
2022-02-07 19:36   ` Nathan Chancellor
2022-02-07 19:38     ` Nick Desaulniers
2022-02-08 13:37 ` Usama Arif [this message]
2022-02-08 13:58 ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2af2d61f-bd3d-5288-7bd2-4768ebe266d7@bytedance.com \
    --to=usama.arif@bytedance.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=trix@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.