KVM Archive mirror
 help / color / mirror / Atom feed
From: Dawid Osuchowski <linux@osuchow.ski>
To: kvm@vger.kernel.org
Cc: alex.williamson@redhat.com, Dawid Osuchowski <linux@osuchow.ski>
Subject: [PATCH] vfio: Use anon_inode_getfile_fmode() in vfio_device_open_file()
Date: Thu, 25 Apr 2024 01:41:47 +0200	[thread overview]
Message-ID: <20240424234147.7840-1-linux@osuchow.ski> (raw)

Remove TODO by using the anon_inode_getfile_fmode() instead of setting
the fmode directly in vfio_device_open_file().

Signed-off-by: Dawid Osuchowski <linux@osuchow.ski>
---
Depends on [1]

[1] https://lore.kernel.org/linux-fsdevel/20240424233859.7640-1-linux@osuchow.ski/T/#u
---
 drivers/vfio/group.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/vfio/group.c b/drivers/vfio/group.c
index 610a429c6191..c9e7af2a1056 100644
--- a/drivers/vfio/group.c
+++ b/drivers/vfio/group.c
@@ -270,22 +270,15 @@ static struct file *vfio_device_open_file(struct vfio_device *device)
 
 	/*
 	 * We can't use anon_inode_getfd() because we need to modify
-	 * the f_mode flags directly to allow more than just ioctls
+	 * the f_mode flags to allow more than just ioctls
 	 */
-	filep = anon_inode_getfile("[vfio-device]", &vfio_device_fops,
-				   df, O_RDWR);
+	filep = anon_inode_getfile_fmode("[vfio-device]", &vfio_device_fops,
+				   df, O_RDWR, FMODE_PREAD | FMODE_PWRITE);
 	if (IS_ERR(filep)) {
 		ret = PTR_ERR(filep);
 		goto err_close_device;
 	}
 
-	/*
-	 * TODO: add an anon_inode interface to do this.
-	 * Appears to be missing by lack of need rather than
-	 * explicitly prevented.  Now there's need.
-	 */
-	filep->f_mode |= (FMODE_PREAD | FMODE_PWRITE);
-
 	if (device->group->type == VFIO_NO_IOMMU)
 		dev_warn(device->dev, "vfio-noiommu device opened by user "
 			 "(%s:%d)\n", current->comm, task_pid_nr(current));
-- 
2.44.0


             reply	other threads:[~2024-04-24 23:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-24 23:41 Dawid Osuchowski [this message]
2024-04-28  7:13 ` [PATCH] vfio: Use anon_inode_getfile_fmode() in vfio_device_open_file() Tian, Kevin

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=20240424234147.7840-1-linux@osuchow.ski \
    --to=linux@osuchow.ski \
    --cc=alex.williamson@redhat.com \
    --cc=kvm@vger.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).