[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200508153634.249933-13-hch@lst.de>
Date: Fri, 8 May 2020 17:36:34 +0200
From: Christoph Hellwig <hch@....de>
To: Alexander Viro <viro@...iv.linux.org.uk>
Cc: linux-integrity@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-gpio@...r.kernel.org, dri-devel@...ts.freedesktop.org,
linux-rdma@...r.kernel.org, kvm@...r.kernel.org,
linux-fsdevel@...r.kernel.org, io-uring@...r.kernel.org,
netdev@...r.kernel.org, bpf@...r.kernel.org
Subject: [PATCH 12/12] vtpm_proxy: use __anon_inode_getfd
Use __anon_inode_getfd instead of opencoding the logic using
get_unused_fd_flags + anon_inode_getfile.
Signed-off-by: Christoph Hellwig <hch@....de>
---
drivers/char/tpm/tpm_vtpm_proxy.c | 23 +++++------------------
1 file changed, 5 insertions(+), 18 deletions(-)
diff --git a/drivers/char/tpm/tpm_vtpm_proxy.c b/drivers/char/tpm/tpm_vtpm_proxy.c
index 91c772e38bb54..4c0a31209ae5a 100644
--- a/drivers/char/tpm/tpm_vtpm_proxy.c
+++ b/drivers/char/tpm/tpm_vtpm_proxy.c
@@ -534,7 +534,7 @@ static struct file *vtpm_proxy_create_device(
struct vtpm_proxy_new_dev *vtpm_new_dev)
{
struct proxy_dev *proxy_dev;
- int rc, fd;
+ int fd;
struct file *file;
if (vtpm_new_dev->flags & ~VTPM_PROXY_FLAGS_ALL)
@@ -546,19 +546,10 @@ static struct file *vtpm_proxy_create_device(
proxy_dev->flags = vtpm_new_dev->flags;
- /* setup an anonymous file for the server-side */
- fd = get_unused_fd_flags(O_RDWR);
- if (fd < 0) {
- rc = fd;
+ fd = __anon_inode_getfd("[vtpms]", &vtpm_proxy_fops, proxy_dev, O_RDWR,
+ &file);
+ if (fd < 0)
goto err_delete_proxy_dev;
- }
-
- file = anon_inode_getfile("[vtpms]", &vtpm_proxy_fops, proxy_dev,
- O_RDWR);
- if (IS_ERR(file)) {
- rc = PTR_ERR(file);
- goto err_put_unused_fd;
- }
/* from now on we can unwind with put_unused_fd() + fput() */
/* simulate an open() on the server side */
@@ -576,13 +567,9 @@ static struct file *vtpm_proxy_create_device(
return file;
-err_put_unused_fd:
- put_unused_fd(fd);
-
err_delete_proxy_dev:
vtpm_proxy_delete_proxy_dev(proxy_dev);
-
- return ERR_PTR(rc);
+ return ERR_PTR(fd);
}
/*
--
2.26.2
Powered by blists - more mailing lists