From: sashiko-bot@kernel.org
To: "Roman Vivchar via B4 Relay" <devnull+rva333.protonmail.com@kernel.org>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
krzk+dt@kernel.org
Subject: Re: [PATCH v2 06/16] nvmem: add mt6323 PMIC EFUSE driver
Date: Wed, 13 May 2026 19:24:07 +0000 [thread overview]
Message-ID: <20260513192408.5E350C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260512-mt6323-v2-6-3efcba579e88@protonmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Unsafe device topology assumption leads to a NULL pointer dereference and kernel panic.
- [Medium] Direct 16-bit assignments to the output buffer cause endianness corruption and potential unaligned memory access.
- [Low] Kconfig help text documents an incorrect module name.
--
commit 4bbd96ffdcf57f8479b893cecdcd10f45fef30fa
Author: Roman Vivchar <rva333@protonmail.com>
nvmem: add mt6323 PMIC EFUSE driver
This commit adds support for the EFUSE controller found in the Mediatek
MT6323 PMIC. It registers an nvmem device to provide access to 24 bytes
of hardware-related data, such as thermal sensor calibration values.
> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
> index 74ddbd0f79b0e..db248a3c4e879 100644
> --- a/drivers/nvmem/Kconfig
> +++ b/drivers/nvmem/Kconfig
[ ... ]
> @@ -227,6 +227,17 @@ config NVMEM_MTK_EFUSE
> This driver can also be built as a module. If so, the module
> will be called efuse-mtk.
>
> +config NVMEM_MT6323_EFUSE
> + tristate "Mediatek MT6323 PMIC EFUSE support"
> + depends on ARCH_MEDIATEK || COMPILE_TEST
> + depends on MFD_MT6397
> + help
> + This is a driver to access hardware related data like sensor
> + calibration, etc.
> +
> + This driver can also be built as a module. If so, the module
> + will be called efuse-mt6323.
This isn't a bug, but the help text says the module will be called
efuse-mt6323, while the Makefile specifies the build target as
nvmem_mt6323-efuse.o.
[ ... ]
> diff --git a/drivers/nvmem/mt6323-efuse.c b/drivers/nvmem/mt6323-efuse.c
> new file mode 100644
> index 0000000000000..52db62784adda
> --- /dev/null
> +++ b/drivers/nvmem/mt6323-efuse.c
> @@ -0,0 +1,86 @@
[ ... ]
> +static int mt6323_efuse_read(void *context, unsigned int offset, void *val,
> + size_t bytes)
> +{
> + struct regmap *map = context;
> + u32 tmp;
> + u16 *buf = val;
> + int ret;
> +
> + /*
> + * Manual regmap_read with loop is needed, because PWRAP is not
> + * a continuous MMIO space, but rather FSM which doesn't implement
> + * necessary read callback for the regmap_read_raw and regmap_read_bulk
> + * functions.
> + */
> + for (size_t i = 0; i < bytes; i += sizeof(*buf)) {
> + ret = regmap_read(map, MT6323_EFUSE_DOUT_BASE + offset + i, &tmp);
> + if (ret)
> + return ret;
> +
> + *buf++ = (u16)tmp;
Does this assignment cause alignment faults or endianness corruption?
The val pointer passed by the NVMEM API is a generic void pointer. Casting it
to a u16 pointer and dereferencing it directly can trigger alignment faults on
architectures that do not support unaligned memory access.
Additionally, this writes the data in the CPU's native byte order, which
results in swapped bytes on big-endian architectures compared to little-endian
architectures. Downstream consumers might expect a consistent data layout.
Could this use put_unaligned_le16() instead to ensure safe memory access and
consistent byte ordering?
> + }
> +
> + return 0;
> +}
> +
> +static int mt6323_efuse_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct nvmem_config config = {
> + .name = "mt6323-efuse",
> + .stride = 2,
> + .word_size = 2,
> + .size = MT6323_EFUSE_SIZE,
> + .reg_read = mt6323_efuse_read,
> + };
> + struct nvmem_device *nvmem;
> + struct regmap *regmap;
> +
> + /* efuse -> mfd -> pwrap */
> + regmap = dev_get_regmap(dev->parent->parent, NULL);
Can dev->parent->parent evaluate to NULL and cause a NULL pointer dereference
here?
The driver registers an of_match_table, meaning it can be instantiated
directly from a Device Tree node. If a malformed or overlay Device Tree places
the node at the root level instead of within the expected PMIC/MFD hierarchy,
the device is instantiated by the top-level platform bus.
In that case, dev->parent is the platform bus, which has no parent, so
dev->parent->parent would be NULL. Passing a NULL device pointer to
dev_get_regmap() will cause an immediate NULL pointer dereference when
devres_find() attempts to acquire the lock.
Would it be safer to verify the existence of the expected parent hierarchy
before dereferencing it?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260512-mt6323-v2-0-3efcba579e88@protonmail.com?part=6
next prev parent reply other threads:[~2026-05-13 19: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 [this message]
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
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=20260513192408.5E350C19425@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