Skip to contentSkip to conversation

irqchip/gic-v3-its: Fix OF node reference leak

PATCH Superseded Yuho Choi 2 participants 3 messages Jun 26

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Yuho Choi

author
#0 lore raw

PATCH v2 1/1 irqchip/gic-v3-its: Fix OF node reference leak

of_get_cpu_node() returns a referenced device node. In its_cpu_init_collection(), the Cavium 23144 workaround only uses the node to compare the CPU NUMA node, but the reference is never dropped.

Use the device_node cleanup helper for the CPU node reference so it is released when leaving the workaround block, including the NUMA mismatch return path.

Fixes fbf8f40e1658 ("irqchip/gicv3-its: numa: Enable workaround for Cavium thunderx erratum 23144")

---
- Use __free(device_node) for the CPU node reference.
- Correct the Fixes tag to fbf8f40e1658.

 drivers/irqchip/irq-gic-v3-its.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +2 -2
index b57d81ad33a0..63942cf1dbe3 100644
@@ -3290,9 +3290,9 @@ static void its_cpu_init_collection(struct its_node *its)
 
 	/* avoid cross node collections and its mapping */
 	if (its->flags & ITS_FLAGS_WORKAROUND_CAVIUM_23144) {
-		struct device_node *cpu_node;
+		struct device_node *cpu_node __free(device_node) =
+			of_get_cpu_node(cpu, NULL);
 
-		cpu_node = of_get_cpu_node(cpu, NULL);
 		if (its->numa_node != NUMA_NO_NODE &&
 			its->numa_node != of_node_to_nid(cpu_node))
 			return;
Signature · 1 line
2.43.0
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 23 lines · Yuho Choi

of_get_cpu_node() returns a referenced device node. In its_cpu_init_collection(), the Cavium 23144 workaround only uses the node to compare the CPU NUMA node, but the reference is never dropped.

Use the device_node cleanup helper for the CPU node reference so it is released when leaving the workaround block, including the NUMA mismatch return path.

Fixes fbf8f40e1658 ("irqchip/gicv3-its: numa: Enable workaround for Cavium thunderx erratum 23144")

---
- Use __free(device_node) for the CPU node reference.
- Correct the Fixes tag to fbf8f40e1658.

 drivers/irqchip/irq-gic-v3-its.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +0 -0
index b57d81ad33a0..63942cf1dbe3 100644

drivers/irqchip/irq-gic-v3-its.c static void its_cpu_init_collection(struct its_node *its) · line 3294

Quoted 6 lines
drivers/irqchip/irq-gic-v3-its.c +2 -1
@@ -3290,9 +3290,9 @@ static void its_cpu_init_collection(struct its_node *its)
 
 	/* avoid cross node collections and its mapping */
 	if (its->flags & ITS_FLAGS_WORKAROUND_CAVIUM_23144) {
-		struct device_node *cpu_node;
+		struct device_node *cpu_node __free(device_node) =
+			of_get_cpu_node(cpu, NULL);

Please keep this on a single line. I find nothing more irritating than these split assignments.

drivers/irqchip/irq-gic-v3-its.c static void its_cpu_init_collection(struct its_node *its) · line 3298

Quoted 5 lines
drivers/irqchip/irq-gic-v3-its.c +0 -1
-		cpu_node = of_get_cpu_node(cpu, NULL);
 		if (its->numa_node != NUMA_NO_NODE &&
 			its->numa_node != of_node_to_nid(cpu_node))
 			return;

Worth taking this opportunity to fix the indentation here.

With these two nits addressed:

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
author
#2 lore raw

Thanks for the review, Marc.

Quoted 4 lines

Please keep this on a single line. I find nothing more irritating than these split assignments.

Worth taking this opportunity to fix the indentation here.

I will fix the assignment formatting and indentation and send v3.

Thanks,
Yuho