]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.60/media-omap3isp-fix-unbalanced-dma_iommu_mapping.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 4.14.60 / media-omap3isp-fix-unbalanced-dma_iommu_mapping.patch
CommitLineData
a65d4bac
GKH
1From foo@baz Sat Jul 28 10:25:26 CEST 2018
2From: Suman Anna <s-anna@ti.com>
3Date: Wed, 14 Mar 2018 11:41:36 -0400
4Subject: media: omap3isp: fix unbalanced dma_iommu_mapping
5
6From: Suman Anna <s-anna@ti.com>
7
8[ Upstream commit b7e1e6859fbf60519fd82d7120cee106a6019512 ]
9
10The OMAP3 ISP driver manages its MMU mappings through the IOMMU-aware
11ARM DMA backend. The current code creates a dma_iommu_mapping and
12attaches this to the ISP device, but never detaches the mapping in
13either the probe failure paths or the driver remove path resulting
14in an unbalanced mapping refcount and a memory leak. Fix this properly.
15
16Reported-by: Pavel Machek <pavel@ucw.cz>
17Signed-off-by: Suman Anna <s-anna@ti.com>
18Tested-by: Pavel Machek <pavel@ucw.cz>
19Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
20Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
21Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
22Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
23Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24---
25 drivers/media/platform/omap3isp/isp.c | 7 ++++---
26 1 file changed, 4 insertions(+), 3 deletions(-)
27
28--- a/drivers/media/platform/omap3isp/isp.c
29+++ b/drivers/media/platform/omap3isp/isp.c
30@@ -1945,6 +1945,7 @@ error_csi2:
31
32 static void isp_detach_iommu(struct isp_device *isp)
33 {
34+ arm_iommu_detach_device(isp->dev);
35 arm_iommu_release_mapping(isp->mapping);
36 isp->mapping = NULL;
37 }
38@@ -1961,8 +1962,7 @@ static int isp_attach_iommu(struct isp_d
39 mapping = arm_iommu_create_mapping(&platform_bus_type, SZ_1G, SZ_2G);
40 if (IS_ERR(mapping)) {
41 dev_err(isp->dev, "failed to create ARM IOMMU mapping\n");
42- ret = PTR_ERR(mapping);
43- goto error;
44+ return PTR_ERR(mapping);
45 }
46
47 isp->mapping = mapping;
48@@ -1977,7 +1977,8 @@ static int isp_attach_iommu(struct isp_d
49 return 0;
50
51 error:
52- isp_detach_iommu(isp);
53+ arm_iommu_release_mapping(isp->mapping);
54+ isp->mapping = NULL;
55 return ret;
56 }
57