Skip to content

Commit 9991a82

Browse files
harshimogalapallijoergroedel
authored andcommitted
iommu/sva: Fix memory leak in iommu_sva_bind_device()
Free the handle when the domain allocation fails before unlocking and returning. Fixes: 092edad ("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>
1 parent a63c357 commit 9991a82

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/iommu/iommu-sva.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm
101101
domain = iommu_sva_domain_alloc(dev, mm);
102102
if (!domain) {
103103
ret = -ENOMEM;
104-
goto out_unlock;
104+
goto out_free_handle;
105105
}
106106

107107
ret = iommu_attach_device_pasid(domain, dev, iommu_mm->pasid);
@@ -118,6 +118,7 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm
118118

119119
out_free_domain:
120120
iommu_domain_free(domain);
121+
out_free_handle:
121122
kfree(handle);
122123
out_unlock:
123124
mutex_unlock(&iommu_sva_lock);

0 commit comments

Comments
 (0)