From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Amit Kucheria <amitk@kernel.org>,
Thara Gopinath <thara.gopinath@gmail.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
Eduardo Valentin <edubezval@gmail.com>,
linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH 04/10] thermal/drivers/qcom/tsens-v1: Validate sensor count before legacy calibration
Date: Thu, 3 Dec 2026 19:54:15 +0000 [thread overview]
Message-ID: <20261203195529.3063246-5-lee@kernel.org> (raw)
In-Reply-To: <20261203195529.3063246-1-lee@kernel.org>
data_tsens_v1 allows up to 11 sensors via tsens_v1_feat.max_sensors,
whereas calibrate_v1() passes 10-element stack arrays p1[10] and p2[10]
and the 10-entry tsens_qcs404_nvmem table to
tsens_read_calibration_legacy() and compute_intercept_slope(). With 11
sensors configured, both read past tsens_qcs404_nvmem.sp and overflow
p1 and p2 on the stack.
Reject legacy calibration in calibrate_v1() when priv->num_sensors
exceeds ARRAY_SIZE(p1).
Fixes: e8c24c6f5d1c ("drivers: thermal: tsens: Add generic support for TSENS v1 IP")
Closes: https://sashiko.dev/#/bug/linux-cb651f32-9e59-4f52-9175-a61de369ed59
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/thermal/qcom/tsens-v1.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
index 7bda8e6087c4..12fe0fbefad4 100644
--- a/drivers/thermal/qcom/tsens-v1.c
+++ b/drivers/thermal/qcom/tsens-v1.c
@@ -49,8 +49,11 @@ static int calibrate_v1(struct tsens_priv *priv)
int mode, ret;
ret = tsens_calibrate_common(priv);
- if (!ret)
- return 0;
+ if (!ret || ret == -EPROBE_DEFER)
+ return ret;
+
+ if (priv->num_sensors > ARRAY_SIZE(p1))
+ return -EINVAL;
qfprom_cdata = (u32 *)qfprom_read(priv->dev, "calib");
if (IS_ERR(qfprom_cdata))
--
2.56.1.911.g883d8bcb20-goog
next prev parent reply other threads:[~2026-12-03 19:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 19:54 [PATCH 00/10] thermal: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-03 19:54 ` Lee Jones [this message]
2026-12-03 19:54 ` [PATCH 05/10] thermal/drivers/qcom/tsens: Bound sensor initialisation by num_sensors Lee Jones
2026-12-03 19:54 ` [PATCH 09/10] thermal/drivers/qcom/tsens: Drop __init from ops init callbacks Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203195529.3063246-5-lee@kernel.org \
--to=lee@kernel.org \
--cc=amitk@kernel.org \
--cc=daniel.lezcano@kernel.org \
--cc=edubezval@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=stable@vger.kernel.org \
--cc=thara.gopinath@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox