Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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")

Signed-off-by: Tuan Phan <tuanphan@os.amperecomputing.com>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/1623946129-3290-1-git-send-email-tuanphan@os.amperecomputing.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Tuan Phan and committed by
Will Deacon
4e16f283 64432f09

+1 -1
+1 -1
drivers/perf/arm-cmn.c
··· 1212 1212 irq = cmn->dtc[i].irq; 1213 1213 for (j = i; j--; ) { 1214 1214 if (cmn->dtc[j].irq == irq) { 1215 - cmn->dtc[j].irq_friend = j - i; 1215 + cmn->dtc[j].irq_friend = i - j; 1216 1216 goto next; 1217 1217 } 1218 1218 }