Skip to contentSkip to conversation

arch: arm: mach-versatile: Add missing of_node_put in integrator.c

PATCH In review heliang 3 participants 4 messages Jun 15, 2022 – Sep 14, 2023

Subsystems (4)
lore
Share & tools
lore

heliang

author
#0 lore raw

PATCH 1/1 arch: arm: mach-versatile: Add missing of_node_put in integrator.c

In cm_init(), of_find_matching_node() will return a node pointer with refcount incremented. We should use of_node_put() when the pointer is not used anymore.

---
 arch/arm/mach-versatile/integrator.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-versatile/integrator.c +1 -0
index fdf9c4db08a7..fba19357171a 100644
@@ -76,6 +76,7 @@ void cm_init(void)
 		return;
 	}
 	cm_base = of_iomap(cm, 0);
+	of_node_put(cm);
 	if (!cm_base) {
 		pr_crit("could not remap core module\n");
 		return;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 5 lines · heliang

In cm_init(), of_find_matching_node() will return a node pointer with refcount incremented. We should use of_node_put() when the pointer is not used anymore.

Patch applied.

Yours,
Linus Walleij

#2 lore raw
In reply to heliang
Quoted 15 lines · heliang

In cm_init(), of_find_matching_node() will return a node pointer with refcount incremented. We should use of_node_put() when the pointer is not used anymore.

---
 arch/arm/mach-versatile/integrator.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-versatile/integrator.c +0 -0
index fdf9c4db08a7..fba19357171a 100644

arch/arm/mach-versatile/integrator.c void cm_init(void) · line 79

Quoted 4 lines
arch/arm/mach-versatile/integrator.c +1 -0
@@ -76,6 +76,7 @@ void cm_init(void)
                return;
        }
        cm_base = of_iomap(cm, 0);
+       of_node_put(cm);

Not really sure this is right. It is in the sense that the DT node is never accessed again. However, the device itself is still accessed and I tend to think a ref to the DT node should be held for that lifetime which in this case is forever. Really, none of this matters because nodes are never removed and these fixes are kind of pointless.

Note that cm_get() and cm_control() are never used and can be removed. That would be the more useful clean-up.

Rob

#3 lore raw
Quoted 11 lines · Rob Herring
Quoted 10 lines · heliang

In cm_init(), of_find_matching_node() will return a node pointer with refcount incremented. We should use of_node_put() when the pointer is not used anymore.

---
 arch/arm/mach-versatile/integrator.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 15 lines

arch/arm/mach-versatile/integrator.c void cm_init(void) · line 79

Quoted 9 lines
arch/arm/mach-versatile/integrator.c +1 -0
index fdf9c4db08a7..fba19357171a 100644
@@ -76,6 +76,7 @@ void cm_init(void)
                return;
        }
        cm_base = of_iomap(cm, 0);
+       of_node_put(cm);

Not really sure this is right. It is in the sense that the DT node is never accessed again. However, the device itself is still accessed and I tend to think a ref to the DT node should be held for that lifetime which in this case is forever. Really, none of this matters because nodes are never removed and these fixes are kind of pointless.

I'm just gonna scrap all these of_node_put() patches these automated static analyzers have sent to the Versatile board and SoC code, it's too dangerous.

Quoted 2 lines

Note that cm_get() and cm_control() are never used and can be removed. That would be the more useful clean-up.

Yeah :/

Yours,
Linus Walleij