[PATCH v8 3/3] perf: marvell: Cancel CN10K DDR PMU hrtimer on device remove
From: Geetha sowjanya
Date: Mon Jun 01 2026 - 03:39:29 EST
cn10k_ddr_perf_remove() did not cancel the poll hrtimer before returning.
If the device was unbound while perf events were still active the timer
callback could run post-free.
To fix the issue by adding hrtimer_cancel() in remove().
Signed-off-by: Geetha sowjanya <gakula@xxxxxxxxxxx>
---
Changes in v8:
- perf: Cancel poll hrtimer in cn10k_ddr_perf_remove() to avoid use-after-free
on device unbind (pre-existing for CN10K/Odyssey).
drivers/perf/marvell_cn10k_ddr_pmu.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/perf/marvell_cn10k_ddr_pmu.c b/drivers/perf/marvell_cn10k_ddr_pmu.c
index 6f638dfe829b..9c82bf4ee2c4 100644
--- a/drivers/perf/marvell_cn10k_ddr_pmu.c
+++ b/drivers/perf/marvell_cn10k_ddr_pmu.c
@@ -1284,6 +1284,12 @@ static void cn10k_ddr_perf_remove(struct platform_device *pdev)
{
struct cn10k_ddr_pmu *ddr_pmu = platform_get_drvdata(pdev);
+ /*
+ * Cancel the poll timer before further teardown so the handler
+ * cannot run after this function returns.
+ */
+ hrtimer_cancel(&ddr_pmu->hrtimer);
+
cpuhp_state_remove_instance_nocalls(
CPUHP_AP_PERF_ARM_MARVELL_CN10K_DDR_ONLINE,
&ddr_pmu->node);
--
2.25.1