提交 9ae9df03 编写于 作者: J Jordan Crouse 提交者: Alex Williamson

iommu: Check the result of iommu_group_get() for NULL

The result of iommu_group_get() was being blindly used in both
attach and detach which results in a dereference when trying
to work with an unknown device.
Signed-off-by: NJordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
上级 1291a0d5
...@@ -1303,6 +1303,9 @@ int iommu_attach_device(struct iommu_domain *domain, struct device *dev) ...@@ -1303,6 +1303,9 @@ int iommu_attach_device(struct iommu_domain *domain, struct device *dev)
int ret; int ret;
group = iommu_group_get(dev); group = iommu_group_get(dev);
if (!group)
return -ENODEV;
/* /*
* Lock the group to make sure the device-count doesn't * Lock the group to make sure the device-count doesn't
* change while we are attaching * change while we are attaching
...@@ -1341,6 +1344,8 @@ void iommu_detach_device(struct iommu_domain *domain, struct device *dev) ...@@ -1341,6 +1344,8 @@ void iommu_detach_device(struct iommu_domain *domain, struct device *dev)
struct iommu_group *group; struct iommu_group *group;
group = iommu_group_get(dev); group = iommu_group_get(dev);
if (!group)
return;
mutex_lock(&group->mutex); mutex_lock(&group->mutex);
if (iommu_group_device_count(group) != 1) { if (iommu_group_device_count(group) != 1) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册