From c90efd1d2ac18de898d89d6d80c21b6f42fc81bd Mon Sep 17 00:00:00 2001 From: Santosh Mardi Date: Sat, 30 Jan 2021 01:39:37 +0530 Subject: [PATCH] drivers: soc: qcom: rimps_memlat: check cpu in idle path In the idle notification, driver saves the mon pmu events to pmu cache memory. Current implementation loops through all the monitors in the group without checking if the given cpu is present in the mon cpumask or not. If the cpu is not present in mon cpumask, the macro to_mon_ev_data in save_mon_pmu_events function can return a wrong address to mon_data which can result in crash. Check if cpu is present in mon cpumask before storing the mon pmu events. Change-Id: Ia2d674fab401dd83f7ce7410607aa4a665851871 Signed-off-by: Santosh Mardi --- drivers/soc/qcom/rimps_memlat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/soc/qcom/rimps_memlat.c b/drivers/soc/qcom/rimps_memlat.c index a7c7e0bbf4d7..018416aa1055 100644 --- a/drivers/soc/qcom/rimps_memlat.c +++ b/drivers/soc/qcom/rimps_memlat.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2013 - 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2013 - 2021, The Linux Foundation. All rights reserved. */ #define pr_fmt(fmt) "rimps-memlat: " fmt @@ -848,6 +848,8 @@ static int memlat_idle_notif(struct notifier_block *nb, save_cpugrp_pmu_events(cpu_grp, cpu); for (i = 0; i < cpu_grp->num_mons; i++) { mon = &cpu_grp->mons[i]; + if (!cpumask_test_cpu(cpu, &mon->cpus)) + continue; save_mon_pmu_events(mon, cpu); } set_pmu_cache_flag(PMU_CACHE_VALID, cpu);