]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
vfio: grab vfio_device reference *before* exposing the sucker via fd_install()
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 18 Aug 2012 01:32:56 +0000 (21:32 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 18 Aug 2012 20:51:28 +0000 (16:51 -0400)
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...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/vfio/vfio.c

index 887ae43276bbdc381140dbd61e70cf1aa562f26d..17830c9c7cc623b7b26cdac7568aca508f7251e7 100644 (file)
@@ -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);