Commit 556f99ac authored by Lu Baolu's avatar Lu Baolu Committed by Joerg Roedel

iommu: Extend mutex lock scope in iommu_probe_device()

Extend the scope of holding group->mutex so that it can cover the default
domain check/attachment and direct mappings of reserved regions.

Cc: Ashish Mhetre <amhetre@nvidia.com>
Fixes: 211ff31b ("iommu: Fix race condition during default domain allocation")
Signed-off-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20211108061349.1985579-1-baolu.lu@linux.intel.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 94aedac4
...@@ -288,11 +288,11 @@ int iommu_probe_device(struct device *dev) ...@@ -288,11 +288,11 @@ int iommu_probe_device(struct device *dev)
*/ */
mutex_lock(&group->mutex); mutex_lock(&group->mutex);
iommu_alloc_default_domain(group, dev); iommu_alloc_default_domain(group, dev);
mutex_unlock(&group->mutex);
if (group->default_domain) { if (group->default_domain) {
ret = __iommu_attach_device(group->default_domain, dev); ret = __iommu_attach_device(group->default_domain, dev);
if (ret) { if (ret) {
mutex_unlock(&group->mutex);
iommu_group_put(group); iommu_group_put(group);
goto err_release; goto err_release;
} }
...@@ -300,6 +300,7 @@ int iommu_probe_device(struct device *dev) ...@@ -300,6 +300,7 @@ int iommu_probe_device(struct device *dev)
iommu_create_device_direct_mappings(group, dev); iommu_create_device_direct_mappings(group, dev);
mutex_unlock(&group->mutex);
iommu_group_put(group); iommu_group_put(group);
if (ops->probe_finalize) if (ops->probe_finalize)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment