Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Christoph Hellwig <hch@lst.de>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	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
Date: Fri, 8 May 2020 16:52:56 -0300	[thread overview]
Message-ID: <20200508195256.GA8912@ziepe.ca> (raw)
In-Reply-To: <20200508153634.249933-10-hch@lst.de>

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 <hch@lst.de>
> ---
>  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

  reply	other threads:[~2020-05-08 19:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08 15:36 Add a __anon_inode_getfd helper Christoph Hellwig
2020-05-08 15:36 ` [PATCH 01/12] fd: add a new " Christoph Hellwig
2020-05-08 15:36 ` [PATCH 02/12] kvm: use __anon_inode_getfd Christoph Hellwig
2020-05-08 15:36 ` [PATCH 03/12] pidfd: " Christoph Hellwig
2020-05-08 15:36 ` [PATCH 04/12] bpf: " Christoph Hellwig
2020-05-08 17:32   ` Andrii Nakryiko
2020-05-08 15:36 ` [PATCH 05/12] io_uring: " Christoph Hellwig
2020-05-08 15:36 ` [PATCH 06/12] eventpoll: " Christoph Hellwig
2020-05-08 15:36 ` [PATCH 07/12] eventfd: " Christoph Hellwig
2020-05-08 15:36 ` [PATCH 08/12] vfio: " Christoph Hellwig
2020-05-08 15:55   ` Alex Williamson
2020-05-08 15:36 ` [PATCH 09/12] rdma: " Christoph Hellwig
2020-05-08 19:52   ` Jason Gunthorpe [this message]
2020-05-08 15:36 ` [PATCH 10/12] drm_syncobj: " Christoph Hellwig
2020-05-08 15:36 ` [PATCH 11/12] gpiolib: " Christoph Hellwig
2020-05-08 15:36 ` [PATCH 12/12] vtpm_proxy: " Christoph Hellwig

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=20200508195256.GA8912@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=bpf@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hch@lst.de \
    --cc=io-uring@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --subject='Re: [PATCH 09/12] rdma: use __anon_inode_getfd' \
    /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

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).