From: sashiko-bot@kernel.org
To: "Roman Vivchar" <rva333@protonmail.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 2/3] nvmem: add mt6323 PMIC EFUSE driver
Date: Fri, 11 Sep 2026 06:51:53 +0000 [thread overview]
Message-ID: <20260911065153.C3DAB1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260911-mt6323-nvmem-v4-2-626dd17531dc@protonmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] NULL pointer dereference when accessing `dev->parent->parent` to retrieve the regmap.
--
commit 9cacac916b33064bc7243868fd8890da0759dff1
Author: Roman Vivchar <rva333@protonmail.com>
nvmem: add mt6323 PMIC EFUSE driver
Add support for the EFUSE controller found in the Mediatek MT6323 PMIC.
The MT6323 EFUSE stores 24 bytes of hardware-related data, such as
thermal sensor calibration values.
> diff --git a/drivers/nvmem/mt6323-efuse.c b/drivers/nvmem/mt6323-efuse.c
> new file mode 100644
> index 0000000000000..6f6f1cdc2f388
> --- /dev/null
> +++ b/drivers/nvmem/mt6323-efuse.c
[ ... ]
> @@ -0,0 +1,84 @@
[ ... ]
> +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);
[Severity: High]
Does this code safely handle cases where the device hierarchy is shallower
than expected?
If the device is instantiated without a grandparent (for example, via a
malformed device tree overlay or manually created via sysfs), dev->parent
will point to the platform_bus, and dev->parent->parent will be NULL.
Passing NULL to dev_get_regmap() forwards it to devres_find(), which then
dereferences the NULL pointer when attempting to take the device's resource
lock.
Additionally, if dev->parent itself is ever NULL, evaluating
dev->parent->parent will crash before the function call even occurs.
> + if (!regmap)
> + return dev_err_probe(dev, -ENODEV, "failed to get regmap\n");
> +
> + config.dev = dev;
> + config.priv = regmap;
> +
> + nvmem = devm_nvmem_register(dev, &config);
> + return PTR_ERR_OR_ZERO(nvmem);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260911-mt6323-nvmem-v4-0-626dd17531dc@protonmail.com?part=2
next prev parent reply other threads:[~2026-09-11 6:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 6:32 [PATCH v4 0/3] nvmem: add support for the MediaTek mt6323 PMIC Roman Vivchar via B4 Relay
2026-09-11 6:32 ` Roman Vivchar
2026-09-11 6:32 ` [PATCH v4 1/3] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE Roman Vivchar via B4 Relay
2026-09-11 6:32 ` Roman Vivchar
2026-09-11 6:41 ` sashiko-bot
2026-09-11 6:33 ` [PATCH v4 2/3] nvmem: add mt6323 PMIC EFUSE driver Roman Vivchar via B4 Relay
2026-09-11 6:33 ` Roman Vivchar
2026-09-11 6:51 ` sashiko-bot [this message]
2026-09-11 6:33 ` [PATCH v4 3/3] ARM: dts: mediatek: mt6323: add EFUSE support Roman Vivchar via B4 Relay
2026-09-11 6:33 ` Roman Vivchar
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=20260911065153.C3DAB1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=rva333@protonmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.