[PATCH] perf/arm-ccn: Set up the DT base before requesting the IRQ

From: hu.shengming

Date: Fri Nov 13 2026 - 06:16:50 EST


From: Qifeng He <he.qifeng1@xxxxxxxxxx>

arm_ccn_probe() requests the CCN interrupt before arm_ccn_pmu_init()
has initialised ccn->dt.base. The interrupt is level-triggered, so a
pending overflow (for example one left behind by a previous kernel
across kexec) is delivered as soon as devm_request_irq() unmasks it.
arm_ccn_pmu_overflow_handler() then dereferences the NULL dt->base:

NULL pointer dereference at virtual address 0x198
pc : arm_ccn_pmu_overflow_handler+0x20
lr : arm_ccn_irq_handler+0x13c

Set up dt->base as soon as the CCN MN block is mapped, before the
interrupt can be requested. The rest of the DT/PMU setup stays in
arm_ccn_pmu_init(); before the PMU is registered the handler only
needs dt->base and the zero-initialised pmu_counters array, so it is
safe to take the interrupt during that window.

Fixes: a33b0daab73a ("bus: ARM CCN PMU driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Qifeng He <he.qifeng1@xxxxxxxxxx>
Signed-off-by: Shengming Hu <hu.shengming@xxxxxxxxxx>
---
drivers/perf/arm-ccn.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/perf/arm-ccn.c b/drivers/perf/arm-ccn.c
index 0c69165e0041..3cbdda843b59 100644
--- a/drivers/perf/arm-ccn.c
+++ b/drivers/perf/arm-ccn.c
@@ -1213,8 +1213,10 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)
char *name;
int err;

- /* Initialize DT subsystem */
- ccn->dt.base = ccn->base + CCN_REGION_SIZE;
+ /*
+ * Initialize the DT subsystem; dt.base was set up in
+ * arm_ccn_probe() before the IRQ was requested.
+ */
spin_lock_init(&ccn->dt.config_lock);
writel(CCN_DT_PMOVSR_CLR__MASK, ccn->dt.base + CCN_DT_PMOVSR_CLR);
writel(CCN_DT_CTL__DT_EN, ccn->dt.base + CCN_DT_CTL);
@@ -1463,6 +1465,14 @@ static int arm_ccn_probe(struct platform_device *pdev)
if (IS_ERR(ccn->base))
return PTR_ERR(ccn->base);

+ /*
+ * The CCN interrupt is level-triggered and may already be pending,
+ * e.g. an overflow left by a previous kernel across kexec. The
+ * handler can run as soon as devm_request_irq() below installs it,
+ * and it dereferences dt->base, so set it up before that.
+ */
+ ccn->dt.base = ccn->base + CCN_REGION_SIZE;
+
irq = platform_get_irq(pdev, 0);
if (irq < 0)
return irq;
--
2.25.1