Skip to contentSkip to conversation

drivers/perf: arm_pmu: avoid CPU device_node reference leak

PATCH RESEND Superseded Will Deacon 2 participants 3 messages Oct 12, 2015 – Oct 15, 2015 Arm PMU profiling and debugging

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 drivers/perf: arm_pmu: avoid CPU device_node reference leak

of_cpu_device_node_get increments the reference count on the CPU device_node, so we must take care to of_node_put once we've finished with it.

This patch fixes the perf IRQ probing code to avoid the leak.

Cc Sudeep Holla <[email protected]>
Cc Mark Rutland <[email protected]>

---

Arnd/Olof: Please can you take this via arm-soc? It's a non-urgent, yet
simple fix and I don't have any other fixes queued for perf.

 drivers/perf/arm_pmu.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/perf/arm_pmu.c +8 -2
index 2365a32a595e..be3755c973e9 100644
@@ -823,9 +823,15 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu)
 		}
 
 		/* Now look up the logical CPU number */
-		for_each_possible_cpu(cpu)
-			if (dn == of_cpu_device_node_get(cpu))
+		for_each_possible_cpu(cpu) {
+			struct device_node *cpu_dn;
+
+			cpu_dn = of_cpu_device_node_get(cpu);
+			of_node_put(cpu_dn);
+
+			if (dn == cpu_dn)
 				break;
+		}
 
 		if (cpu >= nr_cpu_ids) {
 			pr_warn("Failed to find logical CPU for %s\n",
Signature · 1 line
2.1.4
#1 lore raw

PATCH RESEND 1/1 drivers/perf: arm_pmu: avoid CPU device_node reference leak

Quoted 6 lines · Will Deacon

of_cpu_device_node_get increments the reference count on the CPU device_node, so we must take care to of_node_put once we've finished with it.

This patch fixes the perf IRQ probing code to avoid the leak.

Quoted 7 lines
Cc Sudeep Holla <[email protected]>
Cc Mark Rutland <[email protected]>

---

Arnd/Olof: Please can you take this via arm-soc? It's a non-urgent, yet
simple fix and I don't have any other fixes queued for perf.

Ping? I can't see this queued in arm-soc and I'm away next week, so just following up while I can.

Will

Quoted 28 lines
 drivers/perf/arm_pmu.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/perf/arm_pmu.c +8 -2
index 2365a32a595e..be3755c973e9 100644
@@ -823,9 +823,15 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu)
 		}
 
 		/* Now look up the logical CPU number */
-		for_each_possible_cpu(cpu)
-			if (dn == of_cpu_device_node_get(cpu))
+		for_each_possible_cpu(cpu) {
+			struct device_node *cpu_dn;
+
+			cpu_dn = of_cpu_device_node_get(cpu);
+			of_node_put(cpu_dn);
+
+			if (dn == cpu_dn)
 				break;
+		}
 
 		if (cpu >= nr_cpu_ids) {
 			pr_warn("Failed to find logical CPU for %s\n",
Signature · 1 line
2.1.4
#2 lore raw

PATCH RESEND 1/1 drivers/perf: arm_pmu: avoid CPU device_node reference leak

In reply to Will Deacon
Quoted 6 lines · On Monday 12 October 2015 14:48:39 Will Deacon wrote:

of_cpu_device_node_get increments the reference count on the CPU device_node, so we must take care to of_node_put once we've finished with it.

This patch fixes the perf IRQ probing code to avoid the leak.

Quoted 8 lines
Cc Sudeep Holla <[email protected]>
Cc Mark Rutland <[email protected]>

---

Arnd/Olof: Please can you take this via arm-soc? It's a non-urgent, yet
simple fix and I don't have any other fixes queued for perf.

Seems still appropriate for 4.3, so I've put it into the fixes branch. Thanks for the reminder,

Arnd