* [PATCH v2 2/2] thermal/drivers/qcom/tsens: Add support for ipq9650 tsens
2026-06-09 6:54 [PATCH PREVIEW v2 0/2] Add support tsens in ipq5210 & ipq9650 Varadarajan Narayanan
@ 2026-06-09 6:54 ` Varadarajan Narayanan
2026-06-09 7:06 ` sashiko-bot
0 siblings, 1 reply; 6+ messages in thread
From: Varadarajan Narayanan @ 2026-06-09 6:54 UTC (permalink / raw)
To: amitk, thara.gopinath, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, robh, krzk+dt, conor+dt, linux-arm-msm, linux-pm,
devicetree, linux-kernel
Cc: Varadarajan Narayanan, Konrad Dybcio
ipq9650's tsens is similar to ipq5332 tsens but has different number of
sensors. Re-use the ipq5332 data for ipq9650 and modify the sensor related
information.
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
---
drivers/thermal/qcom/tsens-v2.c | 8 ++++++++
drivers/thermal/qcom/tsens.c | 3 +++
drivers/thermal/qcom/tsens.h | 2 +-
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c
index 8d9698ea3ec4..ef1fee2266a3 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},
+ .feat = &ipq5332_feat,
+ .fields = tsens_v2_regfields,
+};
+
/* Kept around for backward compatibility with old msm8996.dtsi */
struct tsens_plat_data data_8996 = {
.num_sensors = 13,
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index a2422ebee816..e7bc622891ca 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -1122,6 +1122,9 @@ static const struct of_device_id tsens_table[] = {
}, {
.compatible = "qcom,ipq8074-tsens",
.data = &data_ipq8074,
+ }, {
+ .compatible = "qcom,ipq9650-tsens",
+ .data = &data_ipq9650,
}, {
.compatible = "qcom,mdm9607-tsens",
.data = &data_9607,
diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h
index 2a7afa4c899b..d9d50d32c962 100644
--- a/drivers/thermal/qcom/tsens.h
+++ b/drivers/thermal/qcom/tsens.h
@@ -657,6 +657,6 @@ extern const struct tsens_plat_data data_ipq5018;
/* TSENS v2 targets */
extern struct tsens_plat_data data_8996, data_ipq8074, data_tsens_v2;
-extern const struct tsens_plat_data data_ipq5332, data_ipq5424;
+extern const struct tsens_plat_data data_ipq5332, data_ipq5424, data_ipq9650;
#endif /* __QCOM_TSENS_H__ */
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] thermal/drivers/qcom/tsens: Add support for ipq9650 tsens
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
0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-06-09 7:06 UTC (permalink / raw)
To: Varadarajan Narayanan; +Cc: robh, conor+dt, devicetree
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The device tree property `#qcom,sensors` can override `num_sensors`, leading to an out-of-bounds read of the static `hw_ids` array and subsequent out-of-bounds array accesses.
--
commit 1557d45f1d577e6cb959599793cf39e4448627b6
Author: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
thermal/drivers/qcom/tsens: Add support for ipq9650 tsens
This commit adds support for the ipq9650 tsens device by reusing the
ipq5332 ops and features, while defining a custom hardware ID array for
its 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 does this hardcoded array expose us to
an out-of-bounds read if the device tree overrides the number of sensors?
In drivers/thermal/qcom/tsens.c:tsens_probe(), the number of sensors can
be overridden by the #qcom,sensors DT property. The probe function later
initializes the sensors in a loop:
for (i = 0; i < priv->num_sensors; i++) {
if (data->hw_ids)
priv->sensor[i].hw_id = data->hw_ids[i];
else
priv->sensor[i].hw_id = i;
}
If a device tree specifies a larger number of sensors than the length of
this new array (for example 12, which is under the MAX_SENSORS limit of 16),
will the initialization loop read past the end of the hw_ids array?
It looks like this could result in garbage values being stored as hw_id,
which are then used as offsets for the fixed-size priv->rf[] regmap field
array, potentially causing arbitrary out-of-bounds pointer dereferences.
> + .feat = &ipq5332_feat,
> + .fields = tsens_v2_regfields,
> +};
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260609065447.4024695-1-varadarajan.narayanan@oss.qualcomm.com?part=2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 0/2] Add support tsens in ipq5210 & ipq9650
@ 2026-06-10 8:12 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
0 siblings, 2 replies; 6+ messages in thread
From: Varadarajan Narayanan @ 2026-06-10 8:12 UTC (permalink / raw)
To: amitk, thara.gopinath, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, robh, krzk+dt, conor+dt, linux-pm, linux-arm-msm,
devicetree, linux-kernel
Cc: Varadarajan Narayanan
ipq5210 and ipq9560 have the Qualcomm tsens-v2 IP. The tsens framework
in these two SoCs are similar to the one found in ipq5332. This series
adds the sensor data to the tsens-v2 driver.
v2: Combine bindings and driver patches
Use fallback for ipq5210 and dropped the driver changes
v1: bindings - https://lore.kernel.org/linux-arm-msm/20260515-tsens-yaml-v1-1-8039c62cc249@oss.qualcomm.com/
driver - https://lore.kernel.org/linux-arm-msm/20260515-tsens-driver-v1-0-015ca76f1418@oss.qualcomm.com/
Varadarajan Narayanan (2):
dt-bindings: thermal: tsens: add ipq5210 & ipq9650 compatible
thermal/drivers/qcom/tsens: Add support for ipq9650 tsens
.../devicetree/bindings/thermal/qcom-tsens.yaml | 9 +++++++++
drivers/thermal/qcom/tsens-v2.c | 8 ++++++++
drivers/thermal/qcom/tsens.c | 3 +++
drivers/thermal/qcom/tsens.h | 2 +-
4 files changed, 21 insertions(+), 1 deletion(-)
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] dt-bindings: thermal: tsens: add ipq5210 & ipq9650 compatible
2026-06-10 8:12 [PATCH v2 0/2] Add support tsens in ipq5210 & ipq9650 Varadarajan Narayanan
@ 2026-06-10 8:12 ` Varadarajan Narayanan
2026-06-10 8:12 ` [PATCH v2 2/2] thermal/drivers/qcom/tsens: Add support for ipq9650 tsens Varadarajan Narayanan
1 sibling, 0 replies; 6+ messages in thread
From: Varadarajan Narayanan @ 2026-06-10 8:12 UTC (permalink / raw)
To: amitk, thara.gopinath, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, robh, krzk+dt, conor+dt, linux-pm, linux-arm-msm,
devicetree, linux-kernel
Cc: Varadarajan Narayanan
Add the compatible for the thermal sensors on the ipq5210 and ipq9650. The
ipq5210 uses ipq5332-tsens as a fallback, while ipq9650 is added as a
standalone v2 TSENS compatible with combined interrupt.
Signed-off-by: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
---
v2: Fix fallback definition
Include ipq9650 to all applicable constraints
---
.../devicetree/bindings/thermal/qcom-tsens.yaml | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
index 7d34ba00e684..5d782c9952c6 100644
--- a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
+++ b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
@@ -92,6 +92,13 @@ properties:
- qcom,ipq5332-tsens
- qcom,ipq5424-tsens
- qcom,ipq8074-tsens
+ - qcom,ipq9650-tsens
+
+ - description: v2 of TSENS with combined interrupt
+ items:
+ - enum:
+ - qcom,ipq5210-tsens
+ - const: qcom,ipq5332-tsens
- description: v2 of TSENS with combined interrupt
items:
@@ -303,6 +310,7 @@ allOf:
- qcom,ipq5332-tsens
- qcom,ipq5424-tsens
- qcom,ipq8074-tsens
+ - qcom,ipq9650-tsens
then:
properties:
interrupts:
@@ -320,6 +328,7 @@ allOf:
- qcom,ipq5332-tsens
- qcom,ipq5424-tsens
- qcom,ipq8074-tsens
+ - qcom,ipq9650-tsens
- qcom,tsens-v0_1
- qcom,tsens-v1
- qcom,tsens-v2
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] thermal/drivers/qcom/tsens: Add support for ipq9650 tsens
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 ` Varadarajan Narayanan
2026-06-10 8:19 ` sashiko-bot
1 sibling, 1 reply; 6+ messages in thread
From: Varadarajan Narayanan @ 2026-06-10 8:12 UTC (permalink / raw)
To: amitk, thara.gopinath, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, robh, krzk+dt, conor+dt, linux-pm, linux-arm-msm,
devicetree, linux-kernel
Cc: Varadarajan Narayanan, Konrad Dybcio
ipq9650's tsens is similar to ipq5332 tsens but has different number of
sensors. Re-use the ipq5332 data for ipq9650 and modify the sensor related
information.
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
---
drivers/thermal/qcom/tsens-v2.c | 8 ++++++++
drivers/thermal/qcom/tsens.c | 3 +++
drivers/thermal/qcom/tsens.h | 2 +-
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c
index 8d9698ea3ec4..ef1fee2266a3 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},
+ .feat = &ipq5332_feat,
+ .fields = tsens_v2_regfields,
+};
+
/* Kept around for backward compatibility with old msm8996.dtsi */
struct tsens_plat_data data_8996 = {
.num_sensors = 13,
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index a2422ebee816..e7bc622891ca 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -1122,6 +1122,9 @@ static const struct of_device_id tsens_table[] = {
}, {
.compatible = "qcom,ipq8074-tsens",
.data = &data_ipq8074,
+ }, {
+ .compatible = "qcom,ipq9650-tsens",
+ .data = &data_ipq9650,
}, {
.compatible = "qcom,mdm9607-tsens",
.data = &data_9607,
diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h
index 2a7afa4c899b..d9d50d32c962 100644
--- a/drivers/thermal/qcom/tsens.h
+++ b/drivers/thermal/qcom/tsens.h
@@ -657,6 +657,6 @@ extern const struct tsens_plat_data data_ipq5018;
/* TSENS v2 targets */
extern struct tsens_plat_data data_8996, data_ipq8074, data_tsens_v2;
-extern const struct tsens_plat_data data_ipq5332, data_ipq5424;
+extern const struct tsens_plat_data data_ipq5332, data_ipq5424, data_ipq9650;
#endif /* __QCOM_TSENS_H__ */
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] thermal/drivers/qcom/tsens: Add support for ipq9650 tsens
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
0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-06-10 8:19 UTC (permalink / raw)
To: Varadarajan Narayanan; +Cc: devicetree, conor+dt, robh
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-10 8:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
-- 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox