Skip to content

Commit

Permalink
vfio: get rid of vfio_device_put()/vfio_group_get_device* races
Browse files Browse the repository at this point in the history
we really need to make sure that dropping the last reference happens
under the group->device_lock; otherwise a loop (under device_lock)
might find vfio_device instance that is being freed right now, has
already dropped the last reference and waits on device_lock to exclude
the sucker from the list.

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 6d2cd3c commit 90b1253
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/vfio/vfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ static void vfio_device_release(struct kref *kref)
struct vfio_device, kref);
struct vfio_group *group = device->group;

mutex_lock(&group->device_lock);
list_del(&device->group_next);
mutex_unlock(&group->device_lock);

Expand All @@ -412,7 +411,7 @@ static void vfio_device_release(struct kref *kref)
static void vfio_device_put(struct vfio_device *device)
{
struct vfio_group *group = device->group;
kref_put(&device->kref, vfio_device_release);
kref_put_mutex(&device->kref, vfio_device_release, &group->device_lock);
vfio_group_put(group);
}

Expand Down

0 comments on commit 90b1253

Please sign in to comment.