Skip to contentSkip to conversation

arch: arm: mach-pxa: Add missing of_node_put in irq.c

PATCH In review heliang 2 participants 2 messages Jun 15, 2022

Subsystems (3)
lore
Share & tools
lore

heliang

author
#0 lore raw

PATCH 1/1 arch: arm: mach-pxa: Add missing of_node_put in irq.c

In pxa_dt_irq_init(), of_find_matching_node() will return a node pointer with refcount incremented. We should use of_node_put in fail path or when it is not used anymore.

---
 arch/arm/mach-pxa/irq.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/mach-pxa/irq.c +4 -0
index 96f33ef1d9ea..a81e9ffb77af 100644
@@ -246,12 +246,14 @@ void __init pxa_dt_irq_init(int (*fn)(struct irq_data *, unsigned int))
 	ret = of_property_read_u32(node, "marvell,intc-nr-irqs",
 				   &pxa_internal_irq_nr);
 	if (ret) {
+		of_node_put(node);
 		pr_err("Not found marvell,intc-nr-irqs property\n");
 		return;
 	}
 
 	ret = of_address_to_resource(node, 0, &res);
 	if (ret < 0) {
+		of_node_put(node);
 		pr_err("No registers defined for node\n");
 		return;
 	}
@@ -262,10 +264,12 @@ void __init pxa_dt_irq_init(int (*fn)(struct irq_data *, unsigned int))
 
 	ret = irq_alloc_descs(-1, 0, pxa_internal_irq_nr, 0);
 	if (ret < 0) {
+		of_node_put(node);
 		pr_err("Failed to allocate IRQ numbers\n");
 		return;
 	}
 
 	pxa_init_irq_common(node, pxa_internal_irq_nr, fn);
+	of_node_put(node);
 }
 #endif /* CONFIG_OF */
Signature · 1 line
2.25.1
maintainer
#1 lore raw

Hi,

Quoted 14 lines · heliang

In pxa_dt_irq_init(), of_find_matching_node() will return a node pointer with refcount incremented. We should use of_node_put in fail path or when it is not used anymore.

---
 arch/arm/mach-pxa/irq.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/mach-pxa/irq.c +0 -0
index 96f33ef1d9ea..a81e9ffb77af 100644

arch/arm/mach-pxa/irq.c void __init pxa_dt_irq_init(int (*fn)(struct irq_data *, unsigned int)) · line 251

Quoted 6 lines
arch/arm/mach-pxa/irq.c +1 -0
@@ -246,12 +246,14 @@ void __init pxa_dt_irq_init(int (*fn)(struct irq_data *, unsigned int))
 	ret = of_property_read_u32(node, "marvell,intc-nr-irqs",
 				   &pxa_internal_irq_nr);
 	if (ret) {
+		of_node_put(node);
 		pr_err("Not found marvell,intc-nr-irqs property\n");
 		return;

How about jumping to a label here instead of a plain "return"?

arch/arm/mach-pxa/irq.c void __init pxa_dt_irq_init(int (*fn)(struct irq_data *, unsigned int)) · line 258

Quoted 7 lines
arch/arm/mach-pxa/irq.c +1 -0
 	}
 
 	ret = of_address_to_resource(node, 0, &res);
 	if (ret < 0) {
+		of_node_put(node);
 		pr_err("No registers defined for node\n");
 		return;

Same here.

arch/arm/mach-pxa/irq.c void __init pxa_dt_irq_init(int (*fn)(struct irq_data *, unsigned int)) · line 269

Quoted 8 lines
arch/arm/mach-pxa/irq.c +1 -0
 	}
@@ -262,10 +264,12 @@ void __init pxa_dt_irq_init(int (*fn)(struct irq_data *, unsigned int))
 
 	ret = irq_alloc_descs(-1, 0, pxa_internal_irq_nr, 0);
 	if (ret < 0) {
+		of_node_put(node);
 		pr_err("Failed to allocate IRQ numbers\n");
 		return;

And here.

arch/arm/mach-pxa/irq.c void __init pxa_dt_irq_init(int (*fn)(struct irq_data *, unsigned int)) · line 272

Quoted 3 lines
arch/arm/mach-pxa/irq.c +0 -0
 	}
 
 	pxa_init_irq_common(node, pxa_internal_irq_nr, fn);

Jump target would go here.

arch/arm/mach-pxa/irq.c void __init pxa_dt_irq_init(int (*fn)(struct irq_data *, unsigned int)) · line 275

Quoted 3 lines
arch/arm/mach-pxa/irq.c +1 -0
+	of_node_put(node);
 }
 #endif /* CONFIG_OF */

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel