Linux IOMMU Development
 help / color / mirror / Atom feed
From: <ye.xingchen@zte.com.cn>
To: <jgg@ziepe.ca>
Cc: <kevin.tian@intel.com>, <joro@8bytes.org>, <will@kernel.org>,
	<robin.murphy@arm.com>, <iommu@lists.linux.dev>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH] iommufd/selftest: Use fdget() and fdput()
Date: Fri, 5 May 2023 14:12:39 +0800 (CST)	[thread overview]
Message-ID: <202305051412396252364@zte.com.cn> (raw)

From: Ye Xingchen <ye.xingchen@zte.com.cn>

convert the fget()/fput() uses to fdget()/fdput().

Signed-off-by: Ye Xingchen <ye.xingchen@zte.com.cn>
---
 drivers/iommu/iommufd/selftest.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
index 74c2076105d4..d3512fa673a5 100644
--- a/drivers/iommu/iommufd/selftest.c
+++ b/drivers/iommu/iommufd/selftest.c
@@ -583,17 +583,16 @@ static const struct file_operations iommfd_test_staccess_fops;

 static struct selftest_access *iommufd_access_get(int fd)
 {
-	struct file *file;
+	struct fd f = fdget(fd);

-	file = fget(fd);
-	if (!file)
+	if (!f.file)
 		return ERR_PTR(-EBADFD);

-	if (file->f_op != &iommfd_test_staccess_fops) {
-		fput(file);
+	if (f.file->f_op != &iommfd_test_staccess_fops) {
+		fdput(f);
 		return ERR_PTR(-EBADFD);
 	}
-	return file->private_data;
+	return f.file->private_data;
 }

 static void iommufd_test_access_unmap(void *data, unsigned long iova,
-- 
2.25.1

             reply	other threads:[~2023-05-05  6:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05  6:12 ye.xingchen [this message]
2023-05-05 11:55 ` [PATCH] iommufd/selftest: Use fdget() and fdput() Jason Gunthorpe

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=202305051412396252364@zte.com.cn \
    --to=ye.xingchen@zte.com.cn \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox