[PATCH 09/12] rdma: use __anon_inode_getfd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use __anon_inode_getfd instead of opencoding the logic using
get_unused_fd_flags + anon_inode_getfile.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
 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;
-	}
 	uobj->object = filp;
-
 	uobj->id = new_fd;
 	return uobj;
 
 err_uobj:
 	uverbs_uobject_put(uobj);
-err_fd:
-	put_unused_fd(new_fd);
 	return uobj;
 }
 
-- 
2.26.2




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux