Commit 08643a87 authored by Jie Gan's avatar Jie Gan Committed by Suzuki K Poulose
Browse files

coresight: cti: fix the check condition in inout_sel_store



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: b5213376 ("coresight: cti: Add sysfs access to program function registers")
Signed-off-by: default avatarJie Gan <jie.gan@oss.qualcomm.com>
Reviewed-by: default avatarLeo Yan <leo.yan@arm.com>
Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20260327-fix-cti-issue-v1-1-2c8921e21fc8@oss.qualcomm.com
parent a9086309
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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);