Skip to content

Commit c225bb4

Browse files
Uuuuuuhogregkh
authored andcommitted
ARM: imx31: Fix IIM mapping leak in revision check
[ Upstream commit ccb4b54 ] mx31_read_cpu_rev() maps the IIM registers with of_iomap() to read the silicon revision, but returns without unmapping the MMIO mapping. Keep the normalized revision value in a local variable and route the return path through iounmap() after the revision register has been read. Fixes: 3172225 ("ARM: imx31: Retrieve the IIM base address from devicetree") Signed-off-by: Yuho Choi <dbgh9129@gmail.com> Signed-off-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ddab66c commit c225bb4

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

arch/arm/mach-imx/cpu-imx31.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static int mx31_read_cpu_rev(void)
3636
void __iomem *iim_base;
3737
struct device_node *np;
3838
u32 i, srev;
39+
int rev = IMX_CHIP_REVISION_UNKNOWN;
3940

4041
np = of_find_compatible_node(NULL, NULL, "fsl,imx31-iim");
4142
iim_base = of_iomap(np, 0);
@@ -48,13 +49,17 @@ static int mx31_read_cpu_rev(void)
4849

4950
for (i = 0; i < ARRAY_SIZE(mx31_cpu_type); i++)
5051
if (srev == mx31_cpu_type[i].srev) {
52+
rev = mx31_cpu_type[i].rev;
5153
imx_print_silicon_rev(mx31_cpu_type[i].name,
5254
mx31_cpu_type[i].rev);
53-
return mx31_cpu_type[i].rev;
55+
goto out;
5456
}
5557

5658
imx_print_silicon_rev("i.MX31", IMX_CHIP_REVISION_UNKNOWN);
57-
return IMX_CHIP_REVISION_UNKNOWN;
59+
60+
out:
61+
iounmap(iim_base);
62+
return rev;
5863
}
5964

6065
int mx31_revision(void)

0 commit comments

Comments
 (0)