]>
Commit | Line | Data |
---|---|---|
a65d4bac GKH |
1 | From foo@baz Sat Jul 28 10:25:26 CEST 2018 |
2 | From: Suman Anna <s-anna@ti.com> | |
3 | Date: Wed, 14 Mar 2018 11:41:36 -0400 | |
4 | Subject: media: omap3isp: fix unbalanced dma_iommu_mapping | |
5 | ||
6 | From: Suman Anna <s-anna@ti.com> | |
7 | ||
8 | [ Upstream commit b7e1e6859fbf60519fd82d7120cee106a6019512 ] | |
9 | ||
10 | The OMAP3 ISP driver manages its MMU mappings through the IOMMU-aware | |
11 | ARM DMA backend. The current code creates a dma_iommu_mapping and | |
12 | attaches this to the ISP device, but never detaches the mapping in | |
13 | either the probe failure paths or the driver remove path resulting | |
14 | in an unbalanced mapping refcount and a memory leak. Fix this properly. | |
15 | ||
16 | Reported-by: Pavel Machek <pavel@ucw.cz> | |
17 | Signed-off-by: Suman Anna <s-anna@ti.com> | |
18 | Tested-by: Pavel Machek <pavel@ucw.cz> | |
19 | Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | |
20 | Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> | |
21 | Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> | |
22 | Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> | |
23 | Signed-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 |