Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Muzaffer Kadir" <muzafferkadir@mainlining.org>
Cc: dmitry.torokhov@gmail.com, conor+dt@kernel.org,
	linux-input@vger.kernel.org, robh@kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v5 4/7] thermal: qcom: tsens: Add support for MSM8952 tsens
Date: Sun, 11 Oct 2026 17:02:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-167330@kernel.org> (raw)
In-Reply-To: <20261011-msm8952-initial-support-v5-4-1857074992ec@mainlining.org>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] thermal: qcom: tsens: OOB write in init_8952() due to missing DT bounds check
- [High] thermal: qcom: tsens: UAF in probe due to __init on init_8952
- [Medium] thermal: qcom: tsens: hardware interrupt left enabled on probe error
--

commit 348b40706a606c87400c1bc3052d8b80b1d7ed76
Author: Muzaffer Kadir <muzafferkadir@mainlining.org>

thermal: qcom: tsens: Add support for MSM8952 tsens

This commit adds support for the TSENS v1 block found on the MSM8952 SoC. It
introduces initialization functions, operations, and platform data for the 11
sensors present on the device. Sensor offsets are adapted from downstream
sources.

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..7bda8e6087c40 100644
> --- a/drivers/thermal/qcom/tsens-v1.c
> +++ b/drivers/thermal/qcom/tsens-v1.c
> @@ -145,6 +145,34 @@ 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 new initialization callback with __init lead to a
use-after-free during a late probe?

The __init attribute means this function's memory is discarded after system
or module initialization.

The tsens_probe() function is not marked __init and executes
priv->ops->init(priv) during its setup phase.

If the platform device defers probing until after .init.text is freed, or
if a user unbinds and rebinds the driver via sysfs, will tsens_probe() jump
to the freed function pointer and cause a use-after-free?

> +{
> +	priv->sensor[0].p1_calib_offset = 2;
> +	priv->sensor[0].p2_calib_offset = -1;

[ ... ]

> +	priv->sensor[9].p2_calib_offset = 0;
> +	priv->sensor[10].p1_calib_offset = -3;
> +	priv->sensor[10].p2_calib_offset = -2;

[Severity: High]
Can this code overflow priv->sensor[]?

In tsens_probe(), the flexible array priv->sensor is dynamically allocated
based on the #qcom,sensors device tree property:

drivers/thermal/qcom/tsens.c:tsens_probe() {
	...
	if (np)
		of_property_read_u32(np, "#qcom,sensors", &num_sensors);
	...
	priv = devm_kzalloc(dev,
			     struct_size(priv, sensor, num_sensors),
			     GFP_KERNEL);
	...
}

If a device tree provides a #qcom,sensors value less than 11, could this
initialization write beyond the allocated bounds of the array and cause a
heap buffer overflow?

> +
> +	return init_common(priv);
> +}

[Severity: Medium]
If a subsequent step in the probe fails, is the hardware interrupt left
enabled?

init_common() sets the INT_EN hardware interrupt flag.

If a later step in tsens_probe() fails, the driver returns directly without
cleaning up the interrupt:

drivers/thermal/qcom/tsens.c:tsens_probe() {
	...
		ret = priv->ops->calibrate(priv);
		if (ret < 0)
			return dev_err_probe(dev, ret, "%s: calibration failed\n",
					     __func__);
	...
	ret = tsens_register(priv);
	if (!ret)
		tsens_debug_init(pdev);

	return ret;
}

If the interrupt fires after the probe exits with an error, the Linux IRQ
subsystem will receive it without a registered handler.

Could this lead to a temporary interrupt storm until the kernel disables the
IRQ line?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261011-msm8952-initial-support-v5-0-1857074992ec@mainlining.org?part=4

  reply	other threads:[~2026-10-11 17:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11 16:51 [PATCH v5 0/7] Add Initial Support For MSM8952, Add General Mobile Shamrock Muzaffer Kadir via B4 Relay
2026-10-11 16:51 ` [PATCH v5 1/7] dt-bindings: nvmem: Add compatible for MSM8952 Muzaffer Kadir via B4 Relay
2026-10-11 16:51 ` [PATCH v5 2/7] dt-bindings: iommu: qcom,iommu: Add MSM8952 IOMMU to SMMUv2 compatibles Muzaffer Kadir via B4 Relay
2026-10-11 16:51 ` [PATCH v5 3/7] dt-bindings: thermal: tsens: Add MSM8952 Muzaffer Kadir via B4 Relay
2026-10-11 16:51 ` [PATCH v5 4/7] thermal: qcom: tsens: Add support for MSM8952 tsens Muzaffer Kadir via B4 Relay
2026-10-11 17:02   ` sashiko-bot [this message]
2026-10-11 16:51 ` [PATCH v5 5/7] arm64: dts: qcom: Add initial support for MSM8952 Muzaffer Kadir via B4 Relay
2026-10-11 17:05   ` sashiko-bot
2026-10-11 16:51 ` [PATCH v5 6/7] dt-bindings: input: touchscreen: goodix: Add binding for GT970 Muzaffer Kadir via B4 Relay
2026-10-11 16:51 ` [PATCH v5 7/7] arm64: dts: qcom: generalmobile-shamrock: new device Muzaffer Kadir via B4 Relay
2026-10-11 17:05   ` sashiko-bot
2026-10-13  8:54 ` [PATCH v5 0/7] Add Initial Support For MSM8952, Add General Mobile Shamrock Daniel Lezcano

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=sashiko-outbox-167330@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --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