Skip to content

Commit 82678ab

Browse files
committed
Merge tag 'iommu-fixes-v6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull iommu fixes from Joerg Roedel: - Fix a regression causing a crash on sysfs access of iommu-group specific files - Fix signedness bug in SVA code * tag 'iommu-fixes-v6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/sva: Fix signedness bug in iommu_sva_alloc_pasid() iommu: Fix crash during syfs iommu_groups/N/type
2 parents b6e6cc1 + c20ecf7 commit 82678ab

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

drivers/iommu/iommu-sva.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ static int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t ma
3434
}
3535

3636
ret = ida_alloc_range(&iommu_global_pasid_ida, min, max, GFP_KERNEL);
37-
if (ret < min)
37+
if (ret < 0)
3838
goto out;
39+
3940
mm->pasid = ret;
4041
ret = 0;
4142
out:

drivers/iommu/iommu.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2891,14 +2891,11 @@ static int iommu_setup_default_domain(struct iommu_group *group,
28912891
ret = __iommu_group_set_domain_internal(
28922892
group, dom, IOMMU_SET_DOMAIN_MUST_SUCCEED);
28932893
if (WARN_ON(ret))
2894-
goto out_free;
2894+
goto out_free_old;
28952895
} else {
28962896
ret = __iommu_group_set_domain(group, dom);
2897-
if (ret) {
2898-
iommu_domain_free(dom);
2899-
group->default_domain = old_dom;
2900-
return ret;
2901-
}
2897+
if (ret)
2898+
goto err_restore_def_domain;
29022899
}
29032900

29042901
/*
@@ -2911,20 +2908,24 @@ static int iommu_setup_default_domain(struct iommu_group *group,
29112908
for_each_group_device(group, gdev) {
29122909
ret = iommu_create_device_direct_mappings(dom, gdev->dev);
29132910
if (ret)
2914-
goto err_restore;
2911+
goto err_restore_domain;
29152912
}
29162913
}
29172914

2918-
err_restore:
2919-
if (old_dom) {
2915+
out_free_old:
2916+
if (old_dom)
2917+
iommu_domain_free(old_dom);
2918+
return ret;
2919+
2920+
err_restore_domain:
2921+
if (old_dom)
29202922
__iommu_group_set_domain_internal(
29212923
group, old_dom, IOMMU_SET_DOMAIN_MUST_SUCCEED);
2924+
err_restore_def_domain:
2925+
if (old_dom) {
29222926
iommu_domain_free(dom);
2923-
old_dom = NULL;
2927+
group->default_domain = old_dom;
29242928
}
2925-
out_free:
2926-
if (old_dom)
2927-
iommu_domain_free(old_dom);
29282929
return ret;
29292930
}
29302931

0 commit comments

Comments
 (0)