From: Jason Gunthorpe Date: Wed, 1 Mar 2023 19:30:19 +0000 (-0400) Subject: iommufd: Add iommufd_lock_obj() around the auto-domains hwpts X-Git-Tag: v6.6.7~2996^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7214c1c85fe464929e9c32f90f81d65cd44b8ff6;p=platform%2Fkernel%2Flinux-starfive.git 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/2-v3-ae9c2975a131+2e1e8-iommufd_hwpt_jgg@nvidia.com Reviewed-by: Kevin Tian Signed-off-by: Jason Gunthorpe --- diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c index dcfaf65..0a80ff7 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.