Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4530139imb; Wed, 6 Mar 2019 16:05:22 -0800 (PST) X-Google-Smtp-Source: APXvYqwzMPzwNDP9eXhPSB69Qu0gV6zD4nerJ4XumgXO+FEYjDeR023vyPT19QuANuGu32s0KOoV X-Received: by 2002:a17:902:6686:: with SMTP id e6mr9765636plk.208.1551917122633; Wed, 06 Mar 2019 16:05:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551917122; cv=none; d=google.com; s=arc-20160816; b=lizlMK4nfpf1aICBgMfK9deT4dddApXbp6otWurmO89fic/grShJEMzVN6rGEkorIk nIV6Wqw9T0ZATQd35s9N914QDltiM8s7bBZs/1pkf3RsHZR0pF7h21Z62Xi3WePtRPvI Q31jmDBH4AVL7BuWeSsaK4HoZQCTKgQwgVZeimSDePEbMYKzBlxF/TEf8Rej4VWCiGVO SIouYAubvRGEijSov0srPGgL92jk5K6QBV4GXF3Ow+9dkyDtXvFc3jln+RzXgq82scrk lNv4au5wvQxdvWLBVB40NmmGN/zaOY0KsA+yeRyyvED2MZpw2HhRtOGWEY7vZOef/GvU bEdg== 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=+PZvv19mgD5D+tqGIUvRT21T/AxNhNS4aW5GrLCwv5M=; b=vCfuX/jIMVykWqJ0bSOCuflKuuCRkoBrg3KWL3oNmFqqwwLv4oUAYDekZeMiEQMSuv efDuTmK9fEEKN6L2Y+WCINQLi8xjKprH9ndVebt8rqEbs/YbxxYrukQi+B2LlZ7RlzwP C+qTq7SgrS1Y4ldJYOJra8Bm59JywB9LqVrPOKRTbh2oX5IYD+CY8//Y1/nrL3xlPOtw dHaIS4xnzh/1ljO+0YM2BRHfNcxb80/gZTRYdwKORnzKhN3PeNmg4m3xE5RcEwf5aYem o0EkSSr9R6zDK+xzyyKmqYjna70/8xLokBHPhL8wdtzzo54zEgEPtaXUDcL9RyAdUiWs DiHw== 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 b1si2493029pgt.559.2019.03.06.16.05.06; Wed, 06 Mar 2019 16:05:22 -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 S1726797AbfCGADi (ORCPT + 99 others); Wed, 6 Mar 2019 19:03:38 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:39996 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726299AbfCGADf (ORCPT ); Wed, 6 Mar 2019 19:03:35 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1h1gVJ-000878-K6; Thu, 07 Mar 2019 00:03: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: Thu, 7 Mar 2019 00:03:15 +0000 Message-Id: <20190307000316.31133-7-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190307000316.31133-1-viro@ZenIV.linux.org.uk> References: <20190307000316.31133-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 5837a29e63fe..af51b1360305 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1029,6 +1029,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); @@ -1805,13 +1810,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; @@ -1883,7 +1884,6 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, return 0; out_put_req: iocb_put(req); -out_put_reqs_available: put_reqs_available(ctx, 1); return ret; } -- 2.11.0