Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b398b596 authored by Patrick Daly's avatar Patrick Daly Committed by Gerrit - the friendly Code Review server
Browse files

iommu: debug: Fix leaky context banks



The contents of struct device->archdata contain private information
for the dma layer and should not be accessed by device drivers.

In this particular instance, the archdata->mapping field is set to
NULL after arm_iommu_detach_device(), leading to
arm_iommu_relase_mapping(NULL). This returns without freeing context
banks or other resources.

Change-Id: I974eb7ddc562e80c2d8a9e5260abf554e20042fa
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
parent ff810a30
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@ static void *test_virt_addr;
struct iommu_debug_device {
	struct device *dev;
	struct iommu_domain *domain;
	struct dma_iommu_mapping *mapping;
	u64 iova;
	u64 phys;
	size_t len;
@@ -1329,6 +1330,8 @@ static ssize_t __iommu_debug_dma_attach_write(struct file *file,

		if (arm_iommu_attach_device(dev, dma_mapping))
			goto out_release_mapping;

		ddev->mapping = dma_mapping;
		pr_err("Attached\n");
	} else {
		if (!dev->archdata.mapping) {
@@ -1342,7 +1345,7 @@ static ssize_t __iommu_debug_dma_attach_write(struct file *file,
			goto out;
		}
		arm_iommu_detach_device(dev);
		arm_iommu_release_mapping(dev->archdata.mapping);
		arm_iommu_release_mapping(ddev->mapping);
		pr_err("Detached\n");
	}
	retval = count;