From: sashiko-bot@kernel.org
To: "Varadarajan Narayanan" <varadarajan.narayanan@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 2/2] thermal/drivers/qcom/tsens: Add support for ipq9650 tsens
Date: Wed, 10 Jun 2026 08:19:43 +0000 [thread overview]
Message-ID: <20260610081943.C6A801F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260610081241.1468507-3-varadarajan.narayanan@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Pre-existing out-of-bounds array read in tsens_probe() when DT overrides `#qcom,sensors`.
--
commit 9a11fba8da339febaef9c47f6f85fc5817527502
Author: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
thermal/drivers/qcom/tsens: Add support for ipq9650 tsens
This commit adds thermal sensor (tsens) support for the ipq9650 platform by
reusing the ipq5332 data and modifying the sensor-related information to
accommodate 11 sensors.
> diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c
> index 8d9698ea3ec40..ef1fee2266a32 100644
> --- a/drivers/thermal/qcom/tsens-v2.c
> +++ b/drivers/thermal/qcom/tsens-v2.c
> @@ -300,6 +300,14 @@ const struct tsens_plat_data data_ipq5424 = {
> .fields = tsens_v2_regfields,
> };
>
> +const struct tsens_plat_data data_ipq9650 = {
> + .num_sensors = 11,
> + .ops = &ops_ipq5332,
> + .hw_ids = (unsigned int []){5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
[Severity: High]
This is a pre-existing issue, but I wanted to ask about how hw_ids[] is
handled if the device tree specifies more sensors than data->num_sensors.
In tsens_probe() in drivers/thermal/qcom/tsens.c, the num_sensors value is
initially set to data->num_sensors, but can be overridden by the device
tree:
drivers/thermal/qcom/tsens.c:tsens_probe() {
...
num_sensors = data->num_sensors;
if (np)
of_property_read_u32(np, "#qcom,sensors", &num_sensors);
...
}
If the overridden num_sensors is larger than data->num_sensors, the
initialization loop will iterate up to the new priv->num_sensors and read
from the statically-sized data->hw_ids[] array:
drivers/thermal/qcom/tsens.c:tsens_probe() {
...
for (i = 0; i < priv->num_sensors; i++) {
if (data->hw_ids)
priv->sensor[i].hw_id = data->hw_ids[i];
...
}
Could this result in an out-of-bounds read if the device tree provides a
malformed or unusually large value for #qcom,sensors, since the hw_ids[]
array here only has 11 elements?
Reading past the end could assign garbage values to hw_id, which later
might cause undefined behavior in functions like get_temp_tsens_valid()
that use hw_id in bit shifts.
> + .feat = &ipq5332_feat,
> + .fields = tsens_v2_regfields,
> +};
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260610081241.1468507-1-varadarajan.narayanan@oss.qualcomm.com?part=2
next prev parent reply other threads:[~2026-06-10 8:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 8:12 [PATCH v2 0/2] Add support tsens in ipq5210 & ipq9650 Varadarajan Narayanan
2026-06-10 8:12 ` [PATCH v2 1/2] dt-bindings: thermal: tsens: add ipq5210 & ipq9650 compatible Varadarajan Narayanan
2026-06-10 8:12 ` [PATCH v2 2/2] thermal/drivers/qcom/tsens: Add support for ipq9650 tsens Varadarajan Narayanan
2026-06-10 8:19 ` sashiko-bot [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-06-09 6:54 [PATCH PREVIEW v2 0/2] Add support tsens in ipq5210 & ipq9650 Varadarajan Narayanan
2026-06-09 6:54 ` [PATCH v2 2/2] thermal/drivers/qcom/tsens: Add support for ipq9650 tsens Varadarajan Narayanan
2026-06-09 7:06 ` sashiko-bot
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=20260610081943.C6A801F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=varadarajan.narayanan@oss.qualcomm.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