vfio: fix possible use after free of vfio group
authorIlya Lesokhin <ilyal@mellanox.com>
Thu, 14 Jul 2016 13:50:19 +0000 (16:50 +0300)
committerAlex Williamson <alex.williamson@redhat.com>
Thu, 14 Jul 2016 20:28:16 +0000 (14:28 -0600)
The vfio group should be released after
the vfio_group_try_dissolve_container call.
The code should not rely on someone else to hold
a reference on the group.

Signed-off-by: Ilya Lesokhin <ilyal@mellanox.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio.c

index 6fd6fa5469def0b8624741938d61a9fc1fc02a70..d1d70e0b011bf41a8d49255a2a4359be342041c7 100644 (file)
@@ -1711,8 +1711,8 @@ EXPORT_SYMBOL_GPL(vfio_group_get_external_user);
 
 void vfio_group_put_external_user(struct vfio_group *group)
 {
-       vfio_group_put(group);
        vfio_group_try_dissolve_container(group);
+       vfio_group_put(group);
 }
 EXPORT_SYMBOL_GPL(vfio_group_put_external_user);