Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Roman Vivchar via B4 Relay" <devnull+rva333.protonmail.com@kernel.org>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org,
	krzk+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 10/16] mfd: mt6397-core: add mt6323 thermal support
Date: Wed, 13 May 2026 20:24:58 +0000	[thread overview]
Message-ID: <20260513202459.010C4C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260512-mt6323-v2-10-3efcba579e88@protonmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The `mtk_pmic_thermal` driver causes a kernel panic (NULL pointer dereference) if instantiated with a malformed device tree that lacks the expected parent hierarchy.
- [High] The `mtk_pmic_thermal` driver aborts probing if the optional `nvmem-cells` device tree property is missing, breaking support for uncalibrated operation and violating its DT binding.
--

commit 3e8b78507795872b5938fe1527d98ac0e8b204df
Author: Roman Vivchar <rva333@protonmail.com>

mfd: mt6397-core: add mt6323 thermal support
    
The mt6323 PMIC temperature can be measured using AUXADC channel.
Register the thermal in the mt6323 devices array to allow the
corresponding driver to probe using compatible string.

> diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
> index 2d9419b80a5c3..061ac242f1f8b 100644
> --- a/drivers/mfd/mt6397-core.c
> +++ b/drivers/mfd/mt6397-core.c
> @@ -151,6 +151,9 @@ static const struct mfd_cell mt6323_devs[] = {
>  		.num_resources = ARRAY_SIZE(mt6323_pwrc_resources),
>  		.resources = mt6323_pwrc_resources,
>  		.of_compatible = "mediatek,mt6323-pwrc"
> +	}, {
> +		.name = "mt6323-thermal",
> +		.of_compatible = "mediatek,mt6323-thermal",

Does the mtk_pmic_thermal driver gracefully handle missing device tree
properties when instantiated here?

Looking at mtk_pmic_thermal_get_calib_data():

drivers/thermal/mediatek/mtk_pmic_thermal.c:mtk_pmic_thermal_get_calib_data() {
	...
	cell = nvmem_cell_get(dev, NULL);
	if (IS_ERR(cell))
		return PTR_ERR(cell);
	...
}

If the optional nvmem-cells property is missing, nvmem_cell_get() returns
an error. This causes the driver to unconditionally abort probing, which
prevents it from reaching its intended default calibration fallback.

Can this also cause a kernel panic if instantiated with a device tree that
lacks the expected parent hierarchy?

Looking at mtk_pmic_thermal_probe():

drivers/thermal/mediatek/mtk_pmic_thermal.c:mtk_pmic_thermal_probe() {
	...
	mt->regmap = dev_get_regmap(dev->parent->parent, NULL);
	if (!mt->regmap)
		return dev_err_probe(dev, -ENODEV, "failed to get regmap");
	...
}

If the thermal device is instantiated from a top-level node rather than as
an MFD child, dev->parent points to the platform_bus device. Because
platform_bus.parent is NULL, dev->parent->parent resolves to NULL. Passing
this NULL pointer to dev_get_regmap() triggers a panic when the core
attempts to acquire the devres_lock spinlock.

>  	},
>  };

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260512-mt6323-v2-0-3efcba579e88@protonmail.com?part=10

  parent reply	other threads:[~2026-05-13 20:24 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12  5:18 [PATCH v2 00/16] add AUXADC, EFUSE and thermal drivers for the MediaTek mt6323 PMIC Roman Vivchar via B4 Relay
2026-05-12  5:18 ` [PATCH v2 01/16] dt-bindings: iio: adc: mt6359: generalize description for mt63xx series Roman Vivchar via B4 Relay
2026-05-12 13:13   ` Jonathan Cameron
2026-05-12 13:55     ` Roman Vivchar
2026-05-12 17:06       ` Jonathan Cameron
2026-05-12  5:18 ` [PATCH v2 02/16] dt-bindings: iio: adc: mt6359: add mt6323 PMIC AUXADC Roman Vivchar via B4 Relay
2026-05-12  5:18 ` [PATCH v2 03/16] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE Roman Vivchar via B4 Relay
2026-05-13  4:44   ` sashiko-bot
2026-05-12  5:18 ` [PATCH v2 04/16] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC thermal Roman Vivchar via B4 Relay
2026-05-13  5:00   ` sashiko-bot
2026-05-12  5:18 ` [PATCH v2 05/16] iio: adc: mediatek: add mt6323 PMIC AUXADC driver Roman Vivchar via B4 Relay
2026-05-12  6:43   ` Andy Shevchenko
2026-05-12 13:29   ` Jonathan Cameron
2026-05-12 14:34     ` Roman Vivchar
2026-05-12 16:56       ` Andy Shevchenko
2026-05-12 17:04       ` Jonathan Cameron
2026-05-13  5:46   ` sashiko-bot
2026-05-12  5:18 ` [PATCH v2 06/16] nvmem: add mt6323 PMIC EFUSE driver Roman Vivchar via B4 Relay
2026-05-12  6:47   ` Andy Shevchenko
2026-05-13 19:24   ` sashiko-bot
2026-05-12  5:18 ` [PATCH v2 07/16] thermal: mediatek: add PMIC thermal support Roman Vivchar via B4 Relay
2026-05-12  7:04   ` Andy Shevchenko
2026-05-12  8:55     ` Roman Vivchar
2026-05-12 11:02       ` Andy Shevchenko
2026-05-12 13:33         ` Jonathan Cameron
2026-05-13 19:57   ` sashiko-bot
2026-05-12  5:18 ` [PATCH v2 08/16] mfd: mt6397-core: add mt6323 AUXADC support Roman Vivchar via B4 Relay
2026-05-12  5:18 ` [PATCH v2 09/16] mfd: mt6397-core: add mt6323 EFUSE support Roman Vivchar via B4 Relay
2026-05-12  5:18 ` [PATCH v2 10/16] mfd: mt6397-core: add mt6323 thermal support Roman Vivchar via B4 Relay
2026-05-12  7:07   ` Andy Shevchenko
2026-05-13 20:24   ` sashiko-bot [this message]
2026-05-12  5:18 ` [PATCH v2 11/16] ARM: dts: mediatek: mt6323: add AUXADC support Roman Vivchar via B4 Relay
2026-05-12  5:18 ` [PATCH v2 12/16] ARM: dts: mediatek: mt6323: add EFUSE support Roman Vivchar via B4 Relay
2026-05-12  5:18 ` [PATCH v2 13/16] ARM: dts: mediatek: mt6323: add thermal support Roman Vivchar via B4 Relay
2026-05-13 20:58   ` sashiko-bot
2026-05-12  5:18 ` [PATCH v2 14/16] MAINTAINERS: add MediaTek mt6323 PMIC AUXADC driver maintainer Roman Vivchar via B4 Relay
2026-05-12 13:36   ` Jonathan Cameron
2026-05-12  5:18 ` [PATCH v2 15/16] MAINTAINERS: add MediaTek mt6323 PMIC EFUSE " Roman Vivchar via B4 Relay
2026-05-12  5:18 ` [PATCH v2 16/16] MAINTAINERS: add MediaTek mt6323 PMIC thermal " Roman Vivchar via B4 Relay

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=20260513202459.010C4C19425@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=devnull+rva333.protonmail.com@kernel.org \
    --cc=krzk+dt@kernel.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