aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Crouse <jcrouse@codeaurora.org>2017-12-20 09:48:36 -0700
committerSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2018-03-21 06:19:20 +0000
commit13b02623a256feb385baf9cee87c80302cf1c3d9 (patch)
tree265ed12aae94554f1598712dcf4cb203e916400d
parent67995dec80af5587da7879c98aadf7e117beeebd (diff)
iommu: Check the result of iommu_group_get() for NULLv4.14/tracking-qcomlt-iommu
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: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
-rw-r--r--drivers/iommu/iommu.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 3de5c0bcb5cc..69fef991c651 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1303,6 +1303,9 @@ int iommu_attach_device(struct iommu_domain *domain, struct device *dev)
int ret;
group = iommu_group_get(dev);
+ if (!group)
+ return -ENODEV;
+
/*
* Lock the group to make sure the device-count doesn't
* change while we are attaching
@@ -1341,6 +1344,8 @@ void iommu_detach_device(struct iommu_domain *domain, struct device *dev)
struct iommu_group *group;
group = iommu_group_get(dev);
+ if (!group)
+ return;
mutex_lock(&group->mutex);
if (iommu_group_device_count(group) != 1) {