Thread (8 messages) flat view 8 messages, 4 authors, 10d ago

Re: [PATCH v4 2/3] nvmem: add mt6323 PMIC EFUSE driver

From: sashiko-bot@kernel.org
Date: 2026-09-11 06:51:58

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 [off-list ref]

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.
quoted hunk ↗ jump to hunk
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
[ ... ]
quoted hunk ↗ jump to hunk
@@ -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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help