From: sashiko-bot@kernel.org
To: "Muzaffer Kadir" <muzafferkadir@mainlining.org>
Cc: mfd@lists.linux.dev, dri-devel@lists.freedesktop.org,
conor+dt@kernel.org, devicetree@vger.kernel.org,
linux-clk@vger.kernel.org, dmitry.torokhov@gmail.com,
linux-input@vger.kernel.org, lee@kernel.org, robh@kernel.org
Subject: Re: [PATCH v3 16/19] thermal: qcom: tsens: Add support for MSM8952 tsens
Date: Mon, 21 Sep 2026 18:30:51 +0000 [thread overview]
Message-ID: <20260921183052.170471F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921-msm8952-initial-support-v3-16-b96fd3fe298b@mainlining.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] thermal: tsens: Use-after-free in tsens_probe() via __init section mismatch
- [High] thermal: tsens: Heap buffer overflow in init_8952() via DT override
--
commit 5408ae137c176a5df112132baa926440df23a1b3
Author: Muzaffer Kadir <muzafferkadir@mainlining.org>
thermal: qcom: tsens: Add support for MSM8952 tsens
This commit adds TSENS thermal sensor support for the Qualcomm MSM8952
platform. It introduces calibration data for 11 sensors and wires up the
associated platform data structure.
Link: https://android.googlesource.com/kernel/msm.git/+/refs/tags/android-wear-7.0.0_r0.3/drivers/thermal/msm-tsens.c#1621
> diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
> index faa5d00788ca6..f4201748ea297 100644
> --- a/drivers/thermal/qcom/tsens-v1.c
> +++ b/drivers/thermal/qcom/tsens-v1.c
> @@ -145,6 +145,37 @@ static const struct reg_field tsens_v1_regfields[MAX_REGFIELDS] = {
> [TRDY] = REG_FIELD(TM_TRDY_OFF, 0, 0),
> };
>
> +static int __init init_8952(struct tsens_priv *priv)
[Severity: High]
Does marking this function as __init risk a use-after-free if the device is
probed late?
If tsens_probe() runs after the initial kernel boot sequence, for instance due
to a standard -EPROBE_DEFER or a manual sysfs bind, the .init.text section
containing this function will have already been freed. Since this function is
assigned to ops_8952.init and invoked dynamically by tsens_probe(), executing
it after boot would jump into freed memory:
drivers/thermal/qcom/tsens.c:tsens_probe() {
...
if (priv->ops->init) {
ret = priv->ops->init(priv);
...
}
> +{
> + for (int i = 0; i < priv->num_sensors; ++i)
> + priv->sensor[i].slope = 3200;
> +
> + priv->sensor[0].p1_calib_offset = 2;
> + priv->sensor[0].p2_calib_offset = -1;
[Severity: High]
Could these unconditional writes overflow the priv->sensor flexible array?
In tsens_probe(), the array size is dynamically allocated based on the
"#qcom,sensors" device tree property:
drivers/thermal/qcom/tsens.c:tsens_probe() {
...
of_property_read_u32(np, "#qcom,sensors", &num_sensors);
...
priv = devm_kzalloc(dev,
struct_size(priv, sensor, num_sensors),
GFP_KERNEL);
...
}
If a malformed or custom device tree overrides this property to a value less
than 11, the array will be allocated with fewer elements. However, this code
unconditionally writes to hardcoded indices up to priv->sensor[10], which
could cause a heap buffer overflow.
> + priv->sensor[1].p1_calib_offset = -4;
> + priv->sensor[1].p2_calib_offset = -4;
[ ... ]
> + priv->sensor[10].p1_calib_offset = -3;
> + priv->sensor[10].p2_calib_offset = -2;
> +
> + return init_common(priv);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260921-msm8952-initial-support-v3-0-b96fd3fe298b@mainlining.org?part=16
next prev parent reply other threads:[~2026-09-21 18:30 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 18:18 [PATCH v3 00/19] Add Initial Support For MSM8952, Add General Mobile Shamrock Muzaffer Kadir via B4 Relay
2026-09-21 18:18 ` [PATCH v3 01/19] dt-bindings: clock: qcom: Add MSM8952 global clock controller Muzaffer Kadir via B4 Relay
2026-09-21 18:25 ` sashiko-bot
2026-09-25 13:39 ` Krzysztof Kozlowski
2026-09-21 18:18 ` [PATCH v3 02/19] clk: qcom: Add global clock controller driver for MSM8952 Muzaffer Kadir via B4 Relay
2026-09-21 18:44 ` sashiko-bot
2026-09-22 20:36 ` Abel Vesa
2026-09-21 18:18 ` [PATCH v3 03/19] dt-bindings: nvmem: Add compatible " Muzaffer Kadir via B4 Relay
2026-09-21 18:21 ` sashiko-bot
2026-09-21 18:18 ` [PATCH v3 04/19] dt-bindings: power: rpmpd: Add MSM8952 power domains Muzaffer Kadir via B4 Relay
2026-09-21 18:23 ` sashiko-bot
2026-09-27 17:47 ` Krzysztof Kozlowski
2026-09-28 13:57 ` Ulf Hansson
2026-09-21 18:18 ` [PATCH v3 05/19] dt-bindings: mmc: sdhci-msm: Add MSM8952 compatible Muzaffer Kadir via B4 Relay
2026-09-21 18:22 ` sashiko-bot
2026-09-27 17:47 ` Krzysztof Kozlowski
2026-09-29 13:34 ` Ulf Hansson
2026-09-21 18:18 ` [PATCH v3 06/19] dt-bindings: vendor-prefixes: Add General Mobile Muzaffer Kadir via B4 Relay
2026-09-21 18:21 ` sashiko-bot
2026-09-21 18:18 ` [PATCH v3 07/19] dt-bindings: arm: qcom: Document MSM8952 SoC binding Muzaffer Kadir via B4 Relay
2026-09-21 18:22 ` sashiko-bot
2026-09-21 18:18 ` [PATCH v3 08/19] dt-bindings: iommu: qcom,iommu: Add MSM8952 IOMMU to SMMUv2 compatibles Muzaffer Kadir via B4 Relay
2026-09-21 18:22 ` sashiko-bot
2026-09-27 17:49 ` Krzysztof Kozlowski
2026-09-21 18:19 ` [PATCH v3 09/19] dt-bindings: mfd: qcom,tcsr: Add compatible for MSM8952 Muzaffer Kadir via B4 Relay
2026-09-21 18:25 ` sashiko-bot
2026-09-27 17:48 ` Krzysztof Kozlowski
2026-09-21 18:19 ` [PATCH v3 10/19] dt-bindings: display/msm: qcom, mdp5: Add MSM8952 compatible Muzaffer Kadir via B4 Relay
2026-09-21 18:24 ` sashiko-bot
2026-09-27 17:48 ` Krzysztof Kozlowski
2026-09-21 18:19 ` [PATCH v3 11/19] dt-bindings: firmware: qcom,scm: Document MSM8952 SCM Muzaffer Kadir via B4 Relay
2026-09-21 18:21 ` sashiko-bot
2026-09-27 17:48 ` Krzysztof Kozlowski
2026-09-21 18:19 ` [PATCH v3 12/19] dt-bindings: clock: qcom,rpmcc: Add MSM8952 compatible Muzaffer Kadir via B4 Relay
2026-09-21 18:26 ` sashiko-bot
2026-09-27 17:50 ` Krzysztof Kozlowski
2026-09-21 18:19 ` [PATCH v3 13/19] drm: msm: mdp5: Add MDP5 configuration for MSM8952 Muzaffer Kadir via B4 Relay
2026-09-21 18:45 ` sashiko-bot
2026-10-01 1:57 ` Dmitry Baryshkov
2026-09-21 18:19 ` [PATCH v3 14/19] soc: qcom: ubwc: Add UBWC config " Muzaffer Kadir via B4 Relay
2026-09-21 18:22 ` sashiko-bot
2026-10-01 1:58 ` Dmitry Baryshkov
2026-09-21 18:19 ` [PATCH v3 15/19] dt-bindings: thermal: tsens: Add MSM8952 Muzaffer Kadir via B4 Relay
2026-09-21 18:26 ` sashiko-bot
2026-09-27 17:51 ` Krzysztof Kozlowski
2026-09-21 18:19 ` [PATCH v3 16/19] thermal: qcom: tsens: Add support for MSM8952 tsens Muzaffer Kadir via B4 Relay
2026-09-21 18:30 ` sashiko-bot [this message]
2026-09-29 7:11 ` Daniel Lezcano
2026-09-29 12:09 ` Muzaffer Kadir
2026-09-21 18:19 ` [PATCH v3 17/19] arm64: dts: qcom: Add initial support for MSM8952 Muzaffer Kadir via B4 Relay
2026-09-21 18:34 ` sashiko-bot
2026-09-21 18:19 ` [PATCH v3 18/19] dt-bindings: input: touchscreen: goodix: Add binding for GT970 Muzaffer Kadir via B4 Relay
2026-09-21 18:29 ` sashiko-bot
2026-09-27 17:52 ` Krzysztof Kozlowski
2026-09-21 18:19 ` [PATCH v3 19/19] arm64: dts: qcom: generalmobile-shamrock: new device Muzaffer Kadir via B4 Relay
2026-09-21 18:37 ` sashiko-bot
2026-10-03 0:46 ` [PATCH v3 00/19] Add Initial Support For MSM8952, Add General Mobile Shamrock Dmitry Baryshkov
2026-10-05 14:00 ` Muzaffer Kadir
2026-10-06 8:53 ` Dmitry Baryshkov
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=20260921183052.170471F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=lee@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=muzafferkadir@mainlining.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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