[PATCH] vfio: Use anon_inode_getfile_fmode() in vfio_device_open_file()

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

 



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@xxxxxxxxxxx>
---
Depends on [1]

[1] https://lore.kernel.org/linux-fsdevel/20240424233859.7640-1-linux@xxxxxxxxxxx/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





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux