static int vfio_group_set_container(struct vfio_group *group, int container_fd)
{
- struct file *filep;
+ struct fd f;
struct vfio_container *container;
struct vfio_iommu_driver *driver;
- int ret = 0, fput_needed;
+ int ret = 0;
if (atomic_read(&group->container_users))
return -EINVAL;
- filep = fget_light(container_fd, &fput_needed);
- if (!filep)
+ f = fdget(container_fd);
+ if (!f.file)
return -EBADF;
/* Sanity check, is this really our fd? */
- if (filep->f_op != &vfio_fops) {
- fput_light(filep, fput_needed);
+ if (f.file->f_op != &vfio_fops) {
+ fdput(f);
return -EINVAL;
}
- container = filep->private_data;
+ container = f.file->private_data;
WARN_ON(!container); /* fget ensures we don't race vfio_release */
mutex_lock(&container->group_lock);
unlock_out:
mutex_unlock(&container->group_lock);
- fput_light(filep, fput_needed);
-
+ fdput(f);
return ret;
}