From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:41621 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725958AbfADQDg (ORCPT ); Fri, 4 Jan 2019 11:03:36 -0500 From: Jeff Moyer To: Chengguang Xu 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() References: <20190104143136.25078-1-cgxu519@gmx.com> Date: Fri, 04 Jan 2019 11:03:35 -0500 In-Reply-To: <20190104143136.25078-1-cgxu519@gmx.com> (Chengguang Xu's message of "Fri, 4 Jan 2019 22:31:36 +0800") Message-ID: MIME-Version: 1.0 Content-Type: text/plain Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Chengguang Xu 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 > --- > 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);