irqchip/gic-v3-its: Fix OF node reference leak
Subsystems (2)
PATCH v3 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.
---
Changes in v3:
- Keep the __free(device_node) assignment on a single line.
- Fix indentation in the Cavium 23144 workaround block.
- Add Marc's Acked-by.
Changes in v2:
- Use __free(device_node) for the CPU node reference.
- Correct the Fixes tag to fbf8f40e1658.
drivers/irqchip/irq-gic-v3-its.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +2 -4
@@ -3290,11 +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)) +if (its->numa_node !=NUMA_NO_NODE && its->numa_node !=of_node_to_nid (cpu_node))return ; }
Signature · 1 line
2.43.0
Quoted 29 lines · Yuho Choi
of_get_cpu_node()returns a referenced device node. Inits_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_nodecleanup 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")Signed-off-by Yuho Choi <[email protected]>Acked-by Marc Zyngier <[email protected]>---
Changes in v3:
- Keep the__free(device_node)assignment on a single line.
- Fix indentation in the Cavium 23144 workaround block.
- Add Marc's Acked-by.
Changes in v2:
- Use__free(device_node)for the CPU node reference.
- Correct the Fixes tag tofbf8f40e1658.drivers/irqchip/irq-gic-v3-its.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/irqchip/irq-gic-v3-its.c +0
-0@@ -3290,11 +3290,9 @@ static void its_cpu_init_collection(struct its_node *its)/* avoid cross node collections and its mapping */
drivers/irqchip/irq-gic-v3-its.c static void its_cpu_init_collection(struct its_node *its) · line 3297
Quoted 10 lines
drivers/irqchip/irq-gic-v3-its.c +2
-4if (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)) +if (its->numa_node !=NUMA_NO_NODE && its->numa_node !=of_node_to_nid (cpu_node))return ; }
Thanks,
Zenghui