]> Git Repo - J-linux.git/commitdiff
iommu/sva: Fix memory leak in iommu_sva_bind_device()
authorHarshit Mogalapalli <[email protected]>
Wed, 13 Dec 2023 11:14:50 +0000 (03:14 -0800)
committerJoerg Roedel <[email protected]>
Fri, 15 Dec 2023 08:06:49 +0000 (09:06 +0100)
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 <[email protected]>
Reviewed-by: Lu Baolu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Joerg Roedel <[email protected]>
drivers/iommu/iommu-sva.c

index 5175e8d85247b2ab69107e0efe115620e54580f8..c3fc9201d0be97e59395750cda0fc29940c0b844 100644 (file)
@@ -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);
This page took 0.072995 seconds and 4 git commands to generate.