[PATCH 07/12] pinctrl: madera: Fix firmware node reference count underflow
From: Dmitry Torokhov
Date: Sat Dec 05 2026 - 01:39:56 EST
madera_pin_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() calls
device_remove_software_node() and fwnode_handle_put(), underflowing the
parent's reference count and prematurely tearing down a parent software
node.
Drop device_set_node() and pass the parent device's firmware node
directly via pinctrl_desc.fwnode instead of mutating the registered
platform device during probe.
Fixes: 218d72a77b0b ("pinctrl: madera: Add driver for Cirrus Logic Madera codecs")
Fixes: ce852837335a ("pinctrl: Propagate firmware node from a parent device")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/pinctrl/cirrus/pinctrl-madera-core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/pinctrl/cirrus/pinctrl-madera-core.c b/drivers/pinctrl/cirrus/pinctrl-madera-core.c
index 61a84e9b07ed..35624208a564 100644
--- a/drivers/pinctrl/cirrus/pinctrl-madera-core.c
+++ b/drivers/pinctrl/cirrus/pinctrl-madera-core.c
@@ -1007,8 +1007,6 @@ static int madera_pin_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "%s\n", __func__);
- device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent));
-
priv = devm_kzalloc_obj(&pdev->dev, *priv);
if (!priv)
return -ENOMEM;
@@ -1049,6 +1047,7 @@ static int madera_pin_probe(struct platform_device *pdev)
return -ENODEV;
madera_pin_desc.npins = priv->chip->n_pins;
+ madera_pin_desc.fwnode = dev_fwnode(pdev->dev.parent);
ret = devm_pinctrl_register_and_init(&pdev->dev,
&madera_pin_desc,
--
2.56.1.987.g2ec0ab4260-goog