diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-08-18 03:32:56 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-08-22 16:26:42 +0200 |
commit | 31605debdf5459cc8aacabf192a911a803a81c26 (patch) | |
tree | 4f7921f9bc1976336afbbbf431450d1d247a6161 /drivers/vfio/vfio.c | |
parent | vfio: get rid of vfio_device_put()/vfio_group_get_device* races (diff) | |
download | linux-31605debdf5459cc8aacabf192a911a803a81c26.tar.xz linux-31605debdf5459cc8aacabf192a911a803a81c26.zip |
vfio: grab vfio_device reference *before* exposing the sucker via fd_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>
Diffstat (limited to '')
-rw-r--r-- | drivers/vfio/vfio.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 887ae43276bb..17830c9c7cc6 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -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); |