2022-04-22 07:53:59

by Miaoqian Lin

[permalink] [raw]
Subject: [PATCH] ARM: imx35: Fix refcount leak in mx35_read_cpu_rev

The of_find_compatible_node() function returns a node pointer with
refcount incremented, We should use of_node_put() on it when done
Add the missing of_node_put() to release the refcount.

Fixes: f68ea682d1da ("ARM: imx35: Retrieve the IIM base address from devicetree")
Signed-off-by: Miaoqian Lin <[email protected]>
---
arch/arm/mach-imx/cpu-imx35.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-imx/cpu-imx35.c b/arch/arm/mach-imx/cpu-imx35.c
index 80e7d8ab9f1b..3ae4a3dc44fb 100644
--- a/arch/arm/mach-imx/cpu-imx35.c
+++ b/arch/arm/mach-imx/cpu-imx35.c
@@ -22,6 +22,7 @@ static int mx35_read_cpu_rev(void)
np = of_find_compatible_node(NULL, NULL, "fsl,imx35-iim");
iim_base = of_iomap(np, 0);
BUG_ON(!iim_base);
+ of_node_put(np);

rev = imx_readl(iim_base + MXC_IIMSREV);
switch (rev) {
--
2.17.1