Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 347911
b: refs/heads/master
c: 9df7b25
h: refs/heads/master
i:
  347909: 9650f3a
  347907: 4d3cb82
  347903: a86bb67
v: v3
  • Loading branch information
Jiang Liu authored and Alex Williamson committed Dec 7, 2012
1 parent 263a1c0 commit 9f38da6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2007722a606bf9f195217f7afd2fbee4bc202c42
refs/heads/master: 9df7b25ab71cee770826d1e7983eb8b6715543d6
31 changes: 15 additions & 16 deletions trunk/drivers/vfio/vfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ static void vfio_container_put(struct vfio_container *container)
kref_put(&container->kref, vfio_container_release);
}

static void vfio_group_unlock_and_free(struct vfio_group *group)
{
mutex_unlock(&vfio.group_lock);
/*
* Unregister outside of lock. A spurious callback is harmless now
* that the group is no longer in vfio.group_list.
*/
iommu_group_unregister_notifier(group->iommu_group, &group->nb);
kfree(group);
}

/**
* Group objects - create, release, get, put, search
*/
Expand Down Expand Up @@ -229,8 +240,7 @@ static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group)

minor = vfio_alloc_group_minor(group);
if (minor < 0) {
mutex_unlock(&vfio.group_lock);
kfree(group);
vfio_group_unlock_and_free(group);
return ERR_PTR(minor);
}

Expand All @@ -239,8 +249,7 @@ static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group)
if (tmp->iommu_group == iommu_group) {
vfio_group_get(tmp);
vfio_free_group_minor(minor);
mutex_unlock(&vfio.group_lock);
kfree(group);
vfio_group_unlock_and_free(group);
return tmp;
}
}
Expand All @@ -249,8 +258,7 @@ static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group)
group, "%d", iommu_group_id(iommu_group));
if (IS_ERR(dev)) {
vfio_free_group_minor(minor);
mutex_unlock(&vfio.group_lock);
kfree(group);
vfio_group_unlock_and_free(group);
return (struct vfio_group *)dev; /* ERR_PTR */
}

Expand All @@ -274,16 +282,7 @@ static void vfio_group_release(struct kref *kref)
device_destroy(vfio.class, MKDEV(MAJOR(vfio.devt), group->minor));
list_del(&group->vfio_next);
vfio_free_group_minor(group->minor);

mutex_unlock(&vfio.group_lock);

/*
* Unregister outside of lock. A spurious callback is harmless now
* that the group is no longer in vfio.group_list.
*/
iommu_group_unregister_notifier(group->iommu_group, &group->nb);

kfree(group);
vfio_group_unlock_and_free(group);
}

static void vfio_group_put(struct vfio_group *group)
Expand Down

0 comments on commit 9f38da6

Please sign in to comment.