Skip to contentSkip to conversation

iommu: Don't overwrite domain pointer when there is no default_domain

PATCH New Joerg Roedel 1 participant 1 message Apr 7, 2016

Subsystems (2)
lore
Share & tools
lore

Joerg Roedel

author maintainer
#0 lore raw

PATCH 1/1 iommu: Don't overwrite domain pointer when there is no default_domain

From: Joerg Roedel <[email protected]>

IOMMU drivers that do not support default domains, but make use of the the group->domain pointer can get that pointer overwritten with NULL on device add/remove.

Make sure this can't happen by only overwriting the domain pointer when it is NULL.

Fixes 1228236de5f9 ('iommu: Move default domain allocation to iommu_group_get_for_dev()')
---
 drivers/iommu/iommu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/iommu.c +2 -1
index bfd4f7c..b9df141 100644
@@ -848,7 +848,8 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev)
 	if (!group->default_domain) {
 		group->default_domain = __iommu_domain_alloc(dev->bus,
 							     IOMMU_DOMAIN_DMA);
-		group->domain = group->default_domain;
+		if (!group->domain)
+			group->domain = group->default_domain;
 	}
 
 	ret = iommu_group_add_device(group, dev);
Signature · 1 line
1.8.4.5