[PATCH v3 2/8] coresight: configfs: Don't assume active until cscfg_mgr is set

James Clark james.clark at linaro.org
Tue Jul 28 08:00:14 PDT 2026


Perf's etm_setup_aux() calls cscfg_activate_config() and dereferences
cscfg_mgr, which can be done after coresight_init() has initialized the
Perf PMU but before cscfg_init() has finished while the driver is still
loading.

Fix it by only assuming cscfg is initialized if cscfg_mgr is set.

Reported-by: sashiko-bot <sashiko-bot at kernel.org>
Fixes: a0114b4740dd ("coresight: etm-perf: Update to activate selected configuration")
Signed-off-by: James Clark <james.clark at linaro.org>
---
 drivers/hwtracing/coresight/coresight-syscfg.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c
index 2bfdd7b45e49..475e8fefa100 100644
--- a/drivers/hwtracing/coresight/coresight-syscfg.c
+++ b/drivers/hwtracing/coresight/coresight-syscfg.c
@@ -581,7 +581,7 @@ int cscfg_load_config_sets(struct cscfg_config_desc **config_descs,
 	int err = 0;
 
 	mutex_lock(&cscfg_mutex);
-	if (cscfg_mgr->load_state != CSCFG_NONE) {
+	if (!cscfg_mgr || cscfg_mgr->load_state != CSCFG_NONE) {
 		mutex_unlock(&cscfg_mutex);
 		return -EBUSY;
 	}
@@ -662,7 +662,7 @@ int cscfg_unload_config_sets(struct cscfg_load_owner_info *owner_info)
 	struct cscfg_load_owner_info *load_list_item = NULL;
 
 	mutex_lock(&cscfg_mutex);
-	if (cscfg_mgr->load_state != CSCFG_NONE) {
+	if (!cscfg_mgr || cscfg_mgr->load_state != CSCFG_NONE) {
 		mutex_unlock(&cscfg_mutex);
 		return -EBUSY;
 	}
@@ -902,7 +902,7 @@ static int _cscfg_activate_config(unsigned long cfg_hash)
 	struct cscfg_config_desc *config_desc;
 	int err = -EINVAL;
 
-	if (cscfg_mgr->load_state == CSCFG_UNLOAD)
+	if (!cscfg_mgr || cscfg_mgr->load_state == CSCFG_UNLOAD)
 		return -EBUSY;
 
 	list_for_each_entry(config_desc, &cscfg_mgr->config_desc_list, item) {

-- 
2.34.1




More information about the linux-arm-kernel mailing list