aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Gunthorpe <[email protected]>2023-03-01 15:30:19 -0400
committerJason Gunthorpe <[email protected]>2023-03-06 10:51:56 -0400
commit7214c1c85fe464929e9c32f90f81d65cd44b8ff6 (patch)
treebb1aa2902ff760c27a2d1f028711ed57c5d8e3dd
parent085fcc7eb759c2b483f85b322e8c5146610010fd (diff)
iommufd: Add iommufd_lock_obj() around the auto-domains hwpts
A later patch will require this locking - currently under the ioas mutex the hwpt can not have a 0 reference and be on the list. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Kevin Tian <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
-rw-r--r--drivers/iommu/iommufd/device.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index dcfaf6567420..0a80ff7b2e0d 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -282,7 +282,10 @@ static int iommufd_device_auto_get_domain(struct iommufd_device *idev,
if (!hwpt->auto_domain)
continue;
+ if (!iommufd_lock_obj(&hwpt->obj))
+ continue;
rc = iommufd_device_do_attach(idev, hwpt);
+ iommufd_put_object(&hwpt->obj);
/*
* -EINVAL means the domain is incompatible with the device.