Unified · Split
| @@ -264,6 +264,7 @@ static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group) · 263 unmodified lines | ||
| 264 | 264 | return group; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | +/* called with vfio.group_lock held */ | |
| 267 | 268 | static void vfio_group_release(struct kref *kref) |
| 268 | 269 | { |
| 269 | 270 | struct vfio_group *group = container_of(kref, struct vfio_group, kref); |
| @@ -287,13 +288,7 @@ static void vfio_group_release(struct kref *kref) · 17 unmodified lines | ||
| 287 | 288 | |
| 288 | 289 | static void vfio_group_put(struct vfio_group *group) |
| 289 | 290 | { |
| 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); | |
| 297 | 292 | } |
| 298 | 293 | |
| 299 | 294 | /* Assume group_lock or group reference is held */ |