Skip to content

Commit

Permalink
vfio: grab vfio_device reference *before* exposing the sucker via fd_…
Browse files Browse the repository at this point in the history
…install()

It's not critical (anymore) since another thread closing the file will block
on ->device_lock before it gets to dropping the final reference, but it's
definitely cleaner that way...

Acked-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Aug 22, 2012
1 parent 90b1253 commit 31605de
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/vfio/vfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1111,10 +1111,10 @@ static int vfio_group_get_device_fd(struct vfio_group *group, char *buf)
*/
filep->f_mode |= (FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE);

fd_install(ret, filep);

vfio_device_get(device);
atomic_inc(&group->container_users);

fd_install(ret, filep);
break;
}
mutex_unlock(&group->device_lock);
Expand Down

0 comments on commit 31605de

Please sign in to comment.