[PATCH 11/12] pinctrl: max7360: Pass parent fwnode via pinctrl_desc
From: Dmitry Torokhov
Date: Sat Dec 05 2026 - 01:40:18 EST
max7360_pinctrl_probe() calls device_set_of_node_from_dev() to copy the
parent MFD device's OF node onto the child platform device. That
mutates a live registered platform device during probe and leaves
dev->of_node and dev->fwnode out of sync, which leaked the OF node
reference on kernels between commit 7b5b51b2b05c ("driver core:
platform: count references to all kinds of firmware nodes") and
commit ff4e64e69415 ("software node: ignore primary nodes in
device_remove_software_node()"), and underflows any secondary software
node attached to the parent OF node during platform_device_release().
Drop device_set_of_node_from_dev() and pass the parent device's firmware
node directly via pinctrl_desc.fwnode.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/pinctrl/pinctrl-max7360.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-max7360.c b/drivers/pinctrl/pinctrl-max7360.c
index fdf2ac8276af..dd2ad55b78c6 100644
--- a/drivers/pinctrl/pinctrl-max7360.c
+++ b/drivers/pinctrl/pinctrl-max7360.c
@@ -14,6 +14,7 @@
#include <linux/mfd/max7360.h>
#include <linux/module.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/stddef.h>
@@ -190,10 +191,10 @@ static int max7360_pinctrl_probe(struct platform_device *pdev)
* This MFD sub-device does not have any associated device tree node:
* properties are stored in the device node of the parent (MFD) device
* and this same node is used in phandles of client devices.
- * Reuse this device tree node here, as otherwise the pinctrl subsystem
- * would be confused by this topology.
+ * Pass this firmware node to the pinctrl core, as otherwise the
+ * pinctrl subsystem would be confused by this topology.
*/
- device_set_of_node_from_dev(dev, dev->parent);
+ pd->fwnode = dev_fwnode(dev->parent);
chip->pctldev = devm_pinctrl_register(dev, pd, chip);
if (IS_ERR(chip->pctldev))
--
2.56.1.987.g2ec0ab4260-goog