dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Muzaffer Kadir" <muzafferkadir@mainlining.org>
Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
	conor+dt@kernel.org, linux-input@vger.kernel.org,
	dmitry.torokhov@gmail.com, mfd@lists.linux.dev, lee@kernel.org,
	dri-devel@lists.freedesktop.org, robh@kernel.org
Subject: Re: [PATCH RFC 17/20] thermal: qcom: tsens: Add support for MSM8952 tsens
Date: Sat, 12 Sep 2026 08:51:24 +0000	[thread overview]
Message-ID: <20260912085125.422BD1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260912-msm8952-initial-support-v1-17-0e742578b524@mainlining.org>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Heap Out-Of-Bounds Write in `init_8952` when device tree overrides `#qcom,sensors`.
- [High] Use-After-Free via Section Mismatch: `init_8952` is annotated with `__init`, but can be called after boot memory is freed.
- [Medium] Potential thermal calibration inaccuracy by replacing SoC-specific logic with hardcoded generics.
--

commit 7ec3bedeaa96c98b6f844188546432e42095ad77
Author: Muzaffer Kadir <muzafferkadir@mainlining.org>

thermal: qcom: tsens: Add support for MSM8952 tsens
    
Add MSM8952 support for tsens.
    
Downstream does a lot of advanced things with calculations.
But seems like using tsens-v1 directly works too.

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]
Since the tsens driver probe can be deferred due to nvmem calibration data
dependencies, or the device could be manually unbound and rebound via sysfs,
could this __init annotation cause a use-after-free?

The ops_8952 struct stores the pointer to this function in .rodata. If the
function is freed after boot memory is reclaimed, calling priv->ops->init()
during a deferred probe will jump to a freed address.

[Severity: Medium]
The commit message notes that downstream does advanced calculations, but this
implementation replaces them with static generic offsets. Could this lead to
thermal calibration inaccuracies?

If these static offsets do not accurately reflect the physical thermal
curves of all MSM8952 chips, could the kernel read skewed temperatures
and fail to act on thermal events?

> +{
> +	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;

[ ... ]

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

[Severity: High]
Could this result in a heap out-of-bounds write?

In tsens_probe(), num_sensors defaults to 11 but can be overridden by the
"#qcom,sensors" device tree property. The priv->sensor array is then
dynamically allocated based on this count using struct_size().

If a device tree specifies a num_sensors value less than 11, these hardcoded
unconditional assignments will write beyond the bounds of the allocated heap
array.

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

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260912-msm8952-initial-support-v1-0-0e742578b524@mainlining.org?part=17

  reply	other threads:[~2026-09-12  8:51 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-12  8:39 [PATCH RFC 00/20] Add Initial Support For MSM8952, Add General Mobile Shamrock Muzaffer Kadir via B4 Relay
2026-09-12  8:39 ` [PATCH RFC 01/20] dt-bindings: clock: qcom: Add MSM8952 global clock controller Muzaffer Kadir via B4 Relay
2026-09-12  8:45   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 02/20] clk: qcom: Add global clock controller driver for MSM8952 Muzaffer Kadir via B4 Relay
2026-09-12  8:54   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 03/20] dt-bindings: nvmem: Add compatible " Muzaffer Kadir via B4 Relay
2026-09-12  8:42   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 04/20] dt-bindings: power: rpmpd: Add MSM8952 power domains Muzaffer Kadir via B4 Relay
2026-09-12  8:42   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 05/20] dt-bindings: mmc: sdhci-msm: Add MSM8952 compatible Muzaffer Kadir via B4 Relay
2026-09-12  8:43   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 06/20] dt-bindings: vendor-prefixes: Add General Mobile Muzaffer Kadir via B4 Relay
2026-09-12  8:41   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 07/20] dt-bindings: arm: qcom: Document MSM8952 SoC binding Muzaffer Kadir via B4 Relay
2026-09-12  8:48   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 08/20] dt-bindings: iommu: qcom,iommu: Add MSM8952 IOMMU to SMMUv2 compatibles Muzaffer Kadir via B4 Relay
2026-09-12  8:42   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 09/20] dt-bindings: mfd: qcom,tcsr: Add compatible for MSM8952 Muzaffer Kadir via B4 Relay
2026-09-12  8:42   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 10/20] dt-bindings: display/msm: qcom, mdp5: Add MSM8952 compatible Muzaffer Kadir via B4 Relay
2026-09-12  8:47   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 11/20] dt-bindings: firmware: qcom,scm: Document MSM8952 SCM Muzaffer Kadir via B4 Relay
2026-09-12  8:44   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 12/20] dt-bindings: clock: qcom,rpmcc: Add MSM8952 compatible Muzaffer Kadir via B4 Relay
2026-09-12  8:46   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 13/20] clk: qcom: smd-rpm: Add clocks for MSM8952 Muzaffer Kadir via B4 Relay
2026-09-12  8:46   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 14/20] drm: msm: mdp5: Add MDP5 configuration " Muzaffer Kadir via B4 Relay
2026-09-12  9:19   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 15/20] soc: qcom: ubwc: Add UBWC config " Muzaffer Kadir via B4 Relay
2026-09-12  8:43   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 16/20] dt-bindings: thermal: tsens: Add MSM8952 Muzaffer Kadir via B4 Relay
2026-09-12  8:51   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 17/20] thermal: qcom: tsens: Add support for MSM8952 tsens Muzaffer Kadir via B4 Relay
2026-09-12  8:51   ` sashiko-bot [this message]
2026-09-12  8:39 ` [PATCH RFC 18/20] arm64: dts: qcom: Add initial support for MSM8952 Muzaffer Kadir via B4 Relay
2026-09-12  8:56   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 19/20] dt-bindings: input: touchscreen: goodix: Add binding for GT970 Muzaffer Kadir via B4 Relay
2026-09-12  8:50   ` sashiko-bot
2026-09-12  8:39 ` [PATCH RFC 20/20] arm64: dts: qcom: generalmobile-shamrock: new device Muzaffer Kadir via B4 Relay
2026-09-12  8:58   ` sashiko-bot
2026-09-12 15:47   ` David Heidelberg
2026-09-12 17:42     ` Muzaffer Kadir

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=20260912085125.422BD1F000FF@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