iommu: fix a reference count leak in iommu_sva_bind_device()
PATCH v2 1/1 iommu: fix a reference count leak in iommu_sva_bind_device()
From: Vasant Karasulli <[email protected]>
commit b34289505180 ("iommu: disable SVA when CONFIG_X86 is set") disables SVA to mitigate a security vulnerability.
Due the current placement of the condition check, function returns after iommu_group_get() without a corresponding iommu_group_put(). So move the condition check above.
This is a stable-only fix applicable to linux-5.15.y.
Fixes b34289505180 ("iommu: disable SVA when CONFIG_X86 is set")
Signed-off-by Vasant Karasulli <[email protected]>
---
v2:
- addressed formatting mistakes in the changelog
drivers/iommu/iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iommu/iommu.c +3 -3
@@ -3061,6 +3061,9 @@ iommu_sva_bind_device(struct device *dev, struct mm_struct *mm, void *drvdata)struct iommu_sva *handle =ERR_PTR (-EINVAL );const struct iommu_ops *ops = dev->bus->iommu_ops; +if (IS_ENABLED (CONFIG_X86 )) +return ERR_PTR (-EOPNOTSUPP ); +if (!ops || !ops->sva_bind)return ERR_PTR (-ENODEV );
@@ -3068,9 +3071,6 @@ iommu_sva_bind_device(struct device *dev, struct mm_struct *mm, void *drvdata)if (!group)return ERR_PTR (-ENODEV ); -if (IS_ENABLED (CONFIG_X86 )) -return ERR_PTR (-EOPNOTSUPP ); -/* Ensure device count and domain don't change while we're binding */ mutex_lock (&group->mutex);
base-commit: 3330a8d33e086f76608bb4e80a3dc569d04a8814
Signature · 1 line
2.34.1