Skip to content

Commit 6d2cd3c

Browse files
author
Al Viro
committed
vfio: get rid of open-coding kref_put_mutex
Acked-by: Alex Williamson <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 8ad5db8 commit 6d2cd3c

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

drivers/vfio/vfio.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group)
264264
return group;
265265
}
266266

267+
/* called with vfio.group_lock held */
267268
static void vfio_group_release(struct kref *kref)
268269
{
269270
struct vfio_group *group = container_of(kref, struct vfio_group, kref);
@@ -287,13 +288,7 @@ static void vfio_group_release(struct kref *kref)
287288

288289
static void vfio_group_put(struct vfio_group *group)
289290
{
290-
mutex_lock(&vfio.group_lock);
291-
/*
292-
* Release needs to unlock to unregister the notifier, so only
293-
* unlock if not released.
294-
*/
295-
if (!kref_put(&group->kref, vfio_group_release))
296-
mutex_unlock(&vfio.group_lock);
291+
kref_put_mutex(&group->kref, vfio_group_release, &vfio.group_lock);
297292
}
298293

299294
/* Assume group_lock or group reference is held */

0 commit comments

Comments
 (0)