[PATCH 04/12] pinctrl: da9062: Fix firmware node reference count underflow

From: Dmitry Torokhov

Date: Sat Dec 05 2026 - 01:39:49 EST


da9062_pctl_probe() attaches the parent MFD device's firmware node to
the child platform device using device_set_node() without taking a
reference. On teardown, platform_device_release() drops a firmware node
reference and removes any attached software node, underflowing the
parent's reference count and prematurely tearing down a parent software
node. When MFD matches a "dlg,da9062-gpio" child DT node via
MFD_CELL_OF, overwriting the platform device's node also leaks that
child node's reference because mfd-core relies on
platform_device_release() to release it.

Since this driver only registers a GPIO chip and not a pin controller,
drop device_set_node() and pass the parent device's firmware node
directly via gpio_chip.fwnode while keeping the platform device as the
GPIO chip parent. Using gpio_chip.fwnode avoids mutating the registered
platform device during probe, preventing re-probe leaks and
platform_device_set_fwnode() warnings on software or secondary nodes.

Fixes: ce852837335a ("pinctrl: Propagate firmware node from a parent device")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/pinctrl/pinctrl-da9062.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-da9062.c b/drivers/pinctrl/pinctrl-da9062.c
index ab62b802bae3..40a2535dbb41 100644
--- a/drivers/pinctrl/pinctrl-da9062.c
+++ b/drivers/pinctrl/pinctrl-da9062.c
@@ -250,8 +250,6 @@ static int da9062_pctl_probe(struct platform_device *pdev)
struct da9062_pctl *pctl;
int i;

- device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent));
-
pctl = devm_kzalloc_obj(&pdev->dev, *pctl);
if (!pctl)
return -ENOMEM;
@@ -273,6 +271,7 @@ static int da9062_pctl_probe(struct platform_device *pdev)
pctl->gc = reference_gc;
pctl->gc.label = dev_name(&pdev->dev);
pctl->gc.parent = &pdev->dev;
+ pctl->gc.fwnode = dev_fwnode(parent);

platform_set_drvdata(pdev, pctl);


--
2.56.1.987.g2ec0ab4260-goog