linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Moyer <jmoyer@redhat.com>
To: Chengguang Xu <cgxu519@gmx.com>
Cc: bcrl@kvack.org, viro@zeniv.linux.org.uk, linux-aio@kvack.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] aio: remove redundant check in ioctx_alloc()
Date: Fri, 04 Jan 2019 11:03:35 -0500	[thread overview]
Message-ID: <x491s5sl8a0.fsf@segfault.boston.devel.redhat.com> (raw)
In-Reply-To: <20190104143136.25078-1-cgxu519@gmx.com> (Chengguang Xu's message of "Fri, 4 Jan 2019 22:31:36 +0800")

Chengguang Xu <cgxu519@gmx.com> writes:

> We don't have to check if nr_events is zero in
> ioctx_alloc() because the caller has already
> done that.

No, this is not a redundant check.  We did some math on that value and
we have to make sure it didn't overflow.

Cheers,
Jeff

>
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
> ---
>  fs/aio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/aio.c b/fs/aio.c
> index b906ff70c90f..7b26c4feb0de 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -720,7 +720,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
>  		return ERR_PTR(-EINVAL);
>  	}
>  
> -	if (!nr_events || (unsigned long)max_reqs > aio_max_nr)
> +	if ((unsigned long)max_reqs > aio_max_nr)
>  		return ERR_PTR(-EAGAIN);
>  
>  	ctx = kmem_cache_zalloc(kioctx_cachep, GFP_KERNEL);

      reply	other threads:[~2019-01-04 16:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-04 14:31 [PATCH] aio: remove redundant check in ioctx_alloc() Chengguang Xu
2019-01-04 16:03 ` Jeff Moyer [this message]

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=x491s5sl8a0.fsf@segfault.boston.devel.redhat.com \
    --to=jmoyer@redhat.com \
    --cc=bcrl@kvack.org \
    --cc=cgxu519@gmx.com \
    --cc=linux-aio@kvack.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).