Skip to contentSkip to conversation

perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number

PATCH Applied Tuan Phan 3 participants 3 messages Jun 17, 2021

Subsystems (2)
lore
Share & tools
lore

Tuan Phan

author
#0 lore raw

PATCH 1/1 perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number

When multiple dtcs share the same IRQ number, the irq_friend which used to refer to dtc object gets calculated incorrect which leads to invalid pointer.

Fixes 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")
---
 drivers/perf/arm-cmn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/arm-cmn.c +1 -1
index 56a5c35..49016f2 100644
@@ -1212,7 +1212,7 @@ static int arm_cmn_init_irqs(struct arm_cmn *cmn)
 		irq = cmn->dtc[i].irq;
 		for (j = i; j--; ) {
 			if (cmn->dtc[j].irq == irq) {
-				cmn->dtc[j].irq_friend = j - i;
+				cmn->dtc[j].irq_friend = i - j;
 				goto next;
 			}
 		}
Signature · 1 line
2.7.4
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Tuan Phan

When multiple dtcs share the same IRQ number, the irq_friend which used to refer to dtc object gets calculated incorrect which leads to invalid pointer.

Oops, indeed this is supposed to be a forward offset *from* the previous match *to* the current dtc. It's almost as if I never managed to test it... :)

Quoted 21 lines
Fixes 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")
---
  drivers/perf/arm-cmn.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/arm-cmn.c +1 -1
index 56a5c35..49016f2 100644
@@ -1212,7 +1212,7 @@ static int arm_cmn_init_irqs(struct arm_cmn *cmn)
  		irq = cmn->dtc[i].irq;
  		for (j = i; j--; ) {
  			if (cmn->dtc[j].irq == irq) {
-				cmn->dtc[j].irq_friend = j - i;
+				cmn->dtc[j].irq_friend = i - j;
  				goto next;
  			}
  		}
maintainer Applied
#2 lore raw
In reply to Tuan Phan
Quoted 5 lines · Tuan Phan

When multiple dtcs share the same IRQ number, the irq_friend which used to refer to dtc object gets calculated incorrect which leads to invalid pointer.

Fixes 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")

Applied to will (for-next/perf), thanks!

[1/1] perf/arm-cmn: Fix invalid pointer when access dtc object sharing the same IRQ number

      https://git.kernel.org/will/c/4e16f283edc2

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev