@@ -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));
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(-)