[PATCH] coresight: cti: fix the check condition in inout_sel_store

Jie Gan jie.gan at oss.qualcomm.com
Thu Mar 26 23:24:14 PDT 2026


Correct the upper bound from CTIINOUTEN_MAX to config->nr_trig_max,
since nr_trig_max varies across CTI devices. An out-of-bounds issue
occurs when a value greater than config->nr_trig_max is provided,
leading to unexpected errors.

Fixes: b5213376c240 ("coresight: cti: Add sysfs access to program function registers")
Signed-off-by: Jie Gan <jie.gan at oss.qualcomm.com>
---
 drivers/hwtracing/coresight/coresight-cti-sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
index 4c0a60840efb..bf3c73607c1c 100644
--- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
+++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
@@ -337,10 +337,11 @@ static ssize_t inout_sel_store(struct device *dev,
 {
 	unsigned long val;
 	struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
+	struct cti_config *config = &drvdata->config;
 
 	if (kstrtoul(buf, 0, &val))
 		return -EINVAL;
-	if (val > (CTIINOUTEN_MAX - 1))
+	if (val >= config->nr_trig_max)
 		return -EINVAL;
 
 	guard(raw_spinlock_irqsave)(&drvdata->spinlock);

---
base-commit: e77a5a5cfe43b4c25bd44a3818e487033287517f
change-id: 20260327-fix-cti-issue-3dda5e4636f7

Best regards,
-- 
Jie Gan <jie.gan at oss.qualcomm.com>




More information about the linux-arm-kernel mailing list