aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorHarshit Mogalapalli <harshit.m.mogalapalli@oracle.com>2023-12-13 03:14:50 -0800
committerJoerg Roedel <jroedel@suse.de>2023-12-15 09:06:49 +0100
commit9991a82a38174672273df44a3cc6c87ef74b18e9 (patch)
tree7ce590f5f49e160eb370a6ccf2f0329cc5af946c /drivers/iommu
parenta63c357b9fd56ad5fe64616f5b22835252c6a76a (diff)
downloadlinux-9991a82a38174672273df44a3cc6c87ef74b18e9.tar.gz
iommu/sva: Fix memory leak in iommu_sva_bind_device()
Free the handle when the domain allocation fails before unlocking and returning. Fixes: 092edaddb660 ("iommu: Support mm PASID 1:n with sva domains") Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Link: https://lore.kernel.org/r/20231213111450.2487861-1-harshit.m.mogalapalli@oracle.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/iommu-sva.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c
index 5175e8d85247b..c3fc9201d0be9 100644
--- a/drivers/iommu/iommu-sva.c
+++ b/drivers/iommu/iommu-sva.c
@@ -101,7 +101,7 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm
domain = iommu_sva_domain_alloc(dev, mm);
if (!domain) {
ret = -ENOMEM;
- goto out_unlock;
+ goto out_free_handle;
}
ret = iommu_attach_device_pasid(domain, dev, iommu_mm->pasid);
@@ -118,6 +118,7 @@ out:
out_free_domain:
iommu_domain_free(domain);
+out_free_handle:
kfree(handle);
out_unlock:
mutex_unlock(&iommu_sva_lock);