aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Gunthorpe <[email protected]>2023-07-17 15:12:07 -0300
committerJason Gunthorpe <[email protected]>2023-07-26 10:20:02 -0300
commit31422dff187b243c58f3a97d16bbe9e9ada639fe (patch)
treebbcd275d2b3a104270b676506cd8df0febab80dc
parent70eadc7fc7ef29bfe0e361376983822b5e36dd67 (diff)
iommufd: Fix locking around hwpt allocation
Due to the auto_domains mechanism the ioas->mutex must be held until the hwpt is completely setup by iommufd_object_abort_and_destroy() or iommufd_object_finalize(). This prevents a concurrent iommufd_device_auto_get_domain() from seeing an incompletely initialized object through the ioas->hwpt_list. To make this more consistent move the unlock until after finalize. Fixes: e8d57210035b ("iommufd: Add kAPI toward external drivers for physical devices") Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Kevin Tian <[email protected]> Tested-by: Nicolin Chen <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
-rw-r--r--drivers/iommu/iommufd/device.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index 08bba99f2fb0..9b9244c5b0ce 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -441,8 +441,8 @@ static int iommufd_device_auto_get_domain(struct iommufd_device *idev,
hwpt->auto_domain = true;
*pt_id = hwpt->obj.id;
- mutex_unlock(&ioas->mutex);
iommufd_object_finalize(idev->ictx, &hwpt->obj);
+ mutex_unlock(&ioas->mutex);
return 0;
out_unlock:
mutex_unlock(&ioas->mutex);