Skip to content

Commit

Permalink
kvm/vfio: Fix potential deadlock problem in vfio
Browse files Browse the repository at this point in the history
Fix following coccicheck warning:
./virt/kvm/vfio.c:258:1-7: preceding lock on line 236

If kvm_vfio_file_iommu_group() failed, code would goto err_fdput with
mutex_lock acquired and then return ret. It might cause potential
deadlock. Move mutex_unlock bellow err_fdput tag to fix it.

Fixes: d55d9e7 ("kvm/vfio: Store the struct file in the kvm_vfio_group")
Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20220517023441.4258-1-wanjiabing@vivo.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
Wan Jiabing authored and Alex Williamson committed May 17, 2022
1 parent 1c05bb9 commit 6b17ca8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion virt/kvm/vfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ static int kvm_vfio_group_set_spapr_tce(struct kvm_device *dev,
break;
}

mutex_unlock(&kv->lock);
err_fdput:
mutex_unlock(&kv->lock);
fdput(f);
return ret;
}
Expand Down

0 comments on commit 6b17ca8

Please sign in to comment.