Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp117257imc; Sat, 9 Mar 2019 23:13:18 -0800 (PST) X-Google-Smtp-Source: APXvYqypAAnhe8cFEJAYTXjVrTfgN9RU2Rp6a+qqAVgMFGvrMq//2JiCgGKwNfg4XdVvUKYONNPg X-Received: by 2002:a63:da43:: with SMTP id l3mr24922564pgj.164.1552201998616; Sat, 09 Mar 2019 23:13:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552201998; cv=none; d=google.com; s=arc-20160816; b=ms3osaqPLy5wtKYmmWWXDm+AIo8dXt/kFYeekjLskBUEAesMVJe2GQ4XELOxyNFVMU 6E2ZOIp8LxTOTnJMSvm5xoa5brx4FM12WnEAJ2SeITGQwemPSALZ78+kUmKkPsAyvWY8 gQVI1BniO04MxJpamxMFf4KmlzbAwJfh3b/9hNmpdsBO42NnB3+3BKoHXbwV4Mec2SoP oHEhzcWWNP07zJMfqNTeoLsrN58N+1i7eocXEBTmNeJZYTAW2c7gfjbPypow8PtSh1AK BnEhPNG0yzRjyQ/yqe0ipuJGh5ZfGySswxMRU44WBnLrTUZvixTCm2VLiGuS7FkLIs5G ZTAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=8Q0yXwCrsjCWFdvyMM680UC7jpS9AU8hEFbuOf+uLjU=; b=nDFd1fZkaFJidcWkvInFGdfYg/XKtY9wo9i5dcjJ6RnjdrHdkQZWS+1Sgcbp3QX/ZJ /kUWuA7wGBdDnwdrtn6DE9iFL85kwtt24fUTwRDPReT75/Ed2CuvajwN41C9PL7aro7B tg+fvNB5G5AGTUxOrlLGNsTsjemWgCHfJdn5qzNl1lxyPEciTYsh2nu8qeAcOgnXWnla ddg3MBNCZDan1VHWID97LlhPcGi74FEDldR9Eb0IiAyD/EaT2NTpXR6bDtrKnfh0y9+4 +sJCAn2QjdIgNrjs2Ykv+xxwNXRitfZGJMp1SbTKcobUHc4Nq6hvW/0nlLlIDdzeuPRn 2gSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64si2555830ply.239.2019.03.09.23.13.03; Sat, 09 Mar 2019 23:13:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726582AbfCJHMF (ORCPT + 99 others); Sun, 10 Mar 2019 03:12:05 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:35534 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726364AbfCJHMF (ORCPT ); Sun, 10 Mar 2019 03:12:05 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1h2sc1-0003D7-Dq; Sun, 10 Mar 2019 07:11:17 +0000 From: Al Viro To: Linus Torvalds Cc: Eric Dumazet , David Miller , Jason Baron , kgraul@linux.ibm.com, ktkhai@virtuozzo.com, kyeongdon.kim@lge.com, Linux List Kernel Mailing , Netdev , pabeni@redhat.com, syzkaller-bugs@googlegroups.com, xiyou.wangcong@gmail.com, Christoph Hellwig , zhengbin , bcrl@kvack.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, houtao1@huawei.com, yi.zhang@huawei.com Subject: [PATCH 7/8] deal with get_reqs_available() in aio_get_req() itself Date: Sun, 10 Mar 2019 07:08:21 +0000 Message-Id: <20190310070822.11564-7-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190310070822.11564-1-viro@ZenIV.linux.org.uk> References: <20190310070606.GA10138@ZenIV.linux.org.uk> <20190310070822.11564-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro simplifies the caller Signed-off-by: Al Viro --- fs/aio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 595c19965a8b..66ca52c57cca 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1033,6 +1033,11 @@ static inline struct aio_kiocb *aio_get_req(struct kioctx *ctx) if (unlikely(!req)) return NULL; + if (unlikely(!get_reqs_available(ctx))) { + kfree(req); + return NULL; + } + percpu_ref_get(&ctx->reqs); req->ki_ctx = ctx; INIT_LIST_HEAD(&req->ki_list); @@ -1796,13 +1801,9 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, return -EINVAL; } - if (!get_reqs_available(ctx)) - return -EAGAIN; - - ret = -EAGAIN; req = aio_get_req(ctx); if (unlikely(!req)) - goto out_put_reqs_available; + return -EAGAIN; req->ki_filp = fget(iocb->aio_fildes); ret = -EBADF; @@ -1877,7 +1878,6 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, out_put_req: iocb_destroy(req); -out_put_reqs_available: put_reqs_available(ctx, 1); return ret; } -- 2.11.0