Skip to content

Commit

Permalink
iommu: Check return of __iommu_attach_device()
Browse files Browse the repository at this point in the history
Currently iommu_create_device_direct_mappings() is called
without checking the return of __iommu_attach_device(). This
may result in failures in iommu driver if dev attach returns
error.

Fixes: ce574c2 ("iommu: Move iommu_group_create_direct_mappings() out of iommu_group_add_device()")
Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Link: https://lore.kernel.org/r/20201119165846.34180-1-shameerali.kolothum.thodi@huawei.com
Signed-off-by: Will Deacon <will@kernel.org>
  • Loading branch information
Shameer Kolothum authored and Will Deacon committed Nov 23, 2020
1 parent 72b55c9 commit 77c38c8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/iommu/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,18 @@ int iommu_probe_device(struct device *dev)
*/
iommu_alloc_default_domain(group, dev);

if (group->default_domain)
if (group->default_domain) {
ret = __iommu_attach_device(group->default_domain, dev);
if (ret) {
iommu_group_put(group);
goto err_release;
}
}

iommu_create_device_direct_mappings(group, dev);

iommu_group_put(group);

if (ret)
goto err_release;

if (ops->probe_finalize)
ops->probe_finalize(dev);

Expand Down

0 comments on commit 77c38c8

Please sign in to comment.