Skip to contentSkip to conversation

sparc32,leon: Fix reference leak in leon_ipi_init

PATCH In review Miaoqian Lin 2 participants 3 messages Jun 5, 2022 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc32,leon: Fix reference leak in leon_ipi_init

of_find_node_by_path() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak.

Fixes 1ca0c808c60f ("sparc32,leon: Implemented SMP IPIs for LEON CPU")
---
 arch/sparc/kernel/leon_smp.c | 1 +
 1 file changed, 1 insertion(+)
arch/sparc/kernel/leon_smp.c +1 -0
index 1eed26d423fb..85b22669c002 100644
@@ -284,6 +284,7 @@ static void __init leon_ipi_init(void)
 		pp = of_find_property(rootnp, "ipi_num", &len);
 		if (pp && (*(int *)pp->value))
 			leon_ipi_irq = *(int *)pp->value;
+		of_node_put(rootnp);
 	}
 	printk(KERN_INFO "leon: SMP IPIs at IRQ %d\n", leon_ipi_irq);
 
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Miaoqian Lin

of_find_node_by_path() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak.

Fixes 1ca0c808c60f ("sparc32,leon: Implemented SMP IPIs for LEON CPU")

The patch is finei, thanks:

All other uses of of_find_node_by_path() in sparc has the same issue. Could you try to take a look at the rest too?

Sam

Quoted 18 lines
---
 arch/sparc/kernel/leon_smp.c | 1 +
 1 file changed, 1 insertion(+)
arch/sparc/kernel/leon_smp.c +1 -0
index 1eed26d423fb..85b22669c002 100644
@@ -284,6 +284,7 @@ static void __init leon_ipi_init(void)
 		pp = of_find_property(rootnp, "ipi_num", &len);
 		if (pp && (*(int *)pp->value))
 			leon_ipi_irq = *(int *)pp->value;
+		of_node_put(rootnp);
 	}
 	printk(KERN_INFO "leon: SMP IPIs at IRQ %d\n", leon_ipi_irq);
 
Signature · 1 line
2.25.1
#2 lore raw
Quoted 5 lines · Sam Ravnborg
Quoted 4 lines · Miaoqian Lin

of_find_node_by_path() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak.

Quoted 7 lines
Quoted 2 lines
Fixes 1ca0c808c60f ("sparc32,leon: Implemented SMP IPIs for LEON CPU")

The patch is finei, thanks:

All other uses of of_find_node_by_path() in sparc has the same issue. Could you try to take a look at the rest too?

Sure, I will look into them.

Quoted 19 lines

Sam

Quoted 18 lines
---
 arch/sparc/kernel/leon_smp.c | 1 +
 1 file changed, 1 insertion(+)
arch/sparc/kernel/leon_smp.c +1 -0
index 1eed26d423fb..85b22669c002 100644
@@ -284,6 +284,7 @@ static void __init leon_ipi_init(void)
 		pp = of_find_property(rootnp, "ipi_num", &len);
 		if (pp && (*(int *)pp->value))
 			leon_ipi_irq = *(int *)pp->value;
+		of_node_put(rootnp);
 	}
 	printk(KERN_INFO "leon: SMP IPIs at IRQ %d\n", leon_ipi_irq);
 
Signature · 1 line
2.25.1