switch simple cases of fget_light to fdget
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -1014,25 +1014,25 @@ static void vfio_group_try_dissolve_container(struct vfio_group *group)
|
||||
|
||||
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);
|
||||
@@ -1054,8 +1054,7 @@ static int vfio_group_set_container(struct vfio_group *group, int container_fd)
|
||||
|
||||
unlock_out:
|
||||
mutex_unlock(&container->group_lock);
|
||||
fput_light(filep, fput_needed);
|
||||
|
||||
fdput(f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user