Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp20855ybk; Fri, 8 May 2020 12:56:42 -0700 (PDT) X-Google-Smtp-Source: APiQypLjRVvEMLVgadPNHN+hVsmrpPSINeGQfxhdpV/DRv0dSzYAdqui9rRdZLKNBiFIyKPs42ET X-Received: by 2002:a17:906:46da:: with SMTP id k26mr3482620ejs.106.1588967802751; Fri, 08 May 2020 12:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588967802; cv=none; d=google.com; s=arc-20160816; b=I9o1gPm/iwYNnHFy77EKJrYB8QHB2waOShtLyi2FfFUIoN3x47bc4bzjfh8jQFlVSi 65hC9VJQ7cO1MrkaqhviKcvZ3kTCH7vVUJrsVLHnebMn470mp1zvwFodkLPW4mO7b8XG E6yBzr0/g7SnMBnpjXFBUm86azfRzqo5PTUWvbvup20fyC23d+FsjxQKa6QE5bqNxj3s HbpVwWh/R7WTj5dVmI4I7QWPHIlla9JmLv3kBcPY0+daybLW24a3hutXmG9X8KJlPVCg czE+vdoJkkuuSsi5CsMmUrLT2yKJurSVcqJakLyuU+3fATJCJwEIBaaBZgZYKRncIaaT fPCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+PiQ6ckxUTnSDo+AGLRh/Fg+o3k0O3ko3wY06x3JoKE=; b=JHr8IQ7Dg88wmr4LI8xpMONRx39ONoPpeOmZeVHro0PYmNKCVOeHcXbkLR7xbaPErH BSqhvIl/9wO3P2Dv3ycFbBW5oguxKoCWnzIsTs2xTwGqO6CXAUkxsozFr8MBAJCM7Gz2 dhvG8UhaK/rZpymIVVYEPoSsfjvO/vEMHd48vYkxJ9EmJyXNAUdwAGtlar18i4J8ZQbU La4COguASJPfFYAYNdf0U0rK3jErQv2FeQhNuK3w0ex/jVh5e+gEtf7zOIzq4xFA40dk v4nlKR5vy6pHCT2Im23wnewzOLJPt1fvS3TfVLOR0onfXAnZe2qLN4b+z/FUs/YUt/+D 0d3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=Ts3CIrEN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w21si1469870ejz.276.2020.05.08.12.56.18; Fri, 08 May 2020 12:56:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=Ts3CIrEN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727874AbgEHTxC (ORCPT + 99 others); Fri, 8 May 2020 15:53:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727828AbgEHTw6 (ORCPT ); Fri, 8 May 2020 15:52:58 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99AB6C05BD0F for ; Fri, 8 May 2020 12:52:58 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id c64so2956876qkf.12 for ; Fri, 08 May 2020 12:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=+PiQ6ckxUTnSDo+AGLRh/Fg+o3k0O3ko3wY06x3JoKE=; b=Ts3CIrENqZECosUV9ufuB6NplQ4bZIANry4cTq9ctiFl2W3eKhj5UpDDQOEaY6A2Yd mNvqS8MpDNbFmXG47isv0LHHuWhU9DrWeNeUqpMHP3rRP+c5b6gcvtAg+8ZLRMd/gdoD 1i8v4D54gKF1JaotzplFLT3nMfQ5VKcTVTMjFomlH2d9ykBhs9YeoAV4r0fEyjl3TlPr v2KDioACvLG1JOHWROC3jtqtFiE8v+6chVfwhJVwQ6LpHrO+DnmO5kWS3VjbGmk9WNEY aeK1VQ7Ix6UqBc9nyw9EdxtaWdyBCOYz2f1ZZWBmiN42UGRN2WCkIjnAj9hWJy7yjUPW HsMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=+PiQ6ckxUTnSDo+AGLRh/Fg+o3k0O3ko3wY06x3JoKE=; b=JsSAu0tMkIvXd7f3wILwPZL3UE4ZlaVj2iuMIN1ewIJ2P8K/lFbnDCVCvKhl3G/KgJ S+OWcW93NDwIyhu78Xuj2EDg6vkIEyeIrD+zsZ0KUcMtDA+SYjNFEE8nHRSiwHgTZdiW Perji2bLAJIaxkokRILCXyZmSU9StqdW1F/uoLpEuLr7enTkUhpuKP/RvW676ImBtgjz 8YYS6KXnIEPBUEvMO7AM8cpX4uetTZOGMhvg2FocBG5FuoDDusHFVzzAWG70QR2O6YYc YzdQANo4rgN6z2n0K2FtuygU71Z6jZiKMon8U5LesKoLcHUOSmYY/7lIEScwnsNI3jR5 4s2Q== X-Gm-Message-State: AGi0PubqH2WXOUGfVSIts+AUuZCIilGYYHbprFugsKTlpmrbsRa7Yvnf COyUlvr1mNAwodQgf+vO5AAKPw== X-Received: by 2002:a37:a4d8:: with SMTP id n207mr4488919qke.354.1588967577470; Fri, 08 May 2020 12:52:57 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id c4sm1945896qkf.120.2020.05.08.12.52.56 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 May 2020 12:52:56 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jX93I-0002SQ-9Q; Fri, 08 May 2020 16:52:56 -0300 Date: Fri, 8 May 2020 16:52:56 -0300 From: Jason Gunthorpe To: Christoph Hellwig Cc: Alexander Viro , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH 09/12] rdma: use __anon_inode_getfd Message-ID: <20200508195256.GA8912@ziepe.ca> References: <20200508153634.249933-1-hch@lst.de> <20200508153634.249933-10-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200508153634.249933-10-hch@lst.de> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 08, 2020 at 05:36:31PM +0200, Christoph Hellwig wrote: > Use __anon_inode_getfd instead of opencoding the logic using > get_unused_fd_flags + anon_inode_getfile. > > Signed-off-by: Christoph Hellwig > --- > drivers/infiniband/core/rdma_core.c | 17 ++++------------- > 1 file changed, 4 insertions(+), 13 deletions(-) > diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c > index 5128cb16bb485..541e5e06347f6 100644 > --- a/drivers/infiniband/core/rdma_core.c > +++ b/drivers/infiniband/core/rdma_core.c > @@ -462,30 +462,21 @@ alloc_begin_fd_uobject(const struct uverbs_api_object *obj, > if (WARN_ON(fd_type->fops->release != &uverbs_uobject_fd_release)) > return ERR_PTR(-EINVAL); > > - new_fd = get_unused_fd_flags(O_CLOEXEC); > - if (new_fd < 0) > - return ERR_PTR(new_fd); > - > uobj = alloc_uobj(attrs, obj); > if (IS_ERR(uobj)) > - goto err_fd; > + return uobj; > > /* Note that uverbs_uobject_fd_release() is called during abort */ > - filp = anon_inode_getfile(fd_type->name, fd_type->fops, NULL, > - fd_type->flags); > - if (IS_ERR(filp)) { > - uobj = ERR_CAST(filp); > + new_fd = __anon_inode_getfd(fd_type->name, fd_type->fops, NULL, > + fd_type->flags | O_CLOEXEC, &filp); > + if (new_fd < 0) > goto err_uobj; This will conflict with a fix (83a267021221 'RDMA/core: Fix overwriting of uobj in case of error') that is going to go to -rc soon. Also the above misses returning an ERR_PTR if __anon_inode_getfd fails, it returns a uobj that had been freed.. I suppose it should be something like if (new_fd < 0) { uverbs_uobject_put(uobj); return ERR_PTR(new_fd) } ? Jason