gpo_twl6040_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. Pass the parent device's firmware node directly via gpio_chip.fwnode while keeping the platform device as the GPIO chip parent. This avoids mutating the registered platform device during probe, preventing re-probe reference leaks and platform_device_set_fwnode() warnings on software or secondary nodes while remaining backportable to older stable kernels. Fixes: 6dbe6c07f94f ("gpio: Propagate firmware node from a parent device") Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov --- drivers/gpio/gpio-twl6040.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c index 4ec9bcd40439..5d64d03344ff 100644 --- a/drivers/gpio/gpio-twl6040.c +++ b/drivers/gpio/gpio-twl6040.c @@ -81,8 +81,6 @@ static int gpo_twl6040_probe(struct platform_device *pdev) struct twl6040 *twl6040 = dev_get_drvdata(twl6040_core_dev); int ret; - device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent)); - twl6040gpo_chip.base = -1; if (twl6040_get_revid(twl6040) < TWL6041_REV_ES2_0) @@ -91,6 +89,7 @@ static int gpo_twl6040_probe(struct platform_device *pdev) twl6040gpo_chip.ngpio = 1; /* twl6041 have 1 GPO */ twl6040gpo_chip.parent = &pdev->dev; + twl6040gpo_chip.fwnode = dev_fwnode(twl6040_core_dev); ret = devm_gpiochip_add_data(&pdev->dev, &twl6040gpo_chip, twl6040); if (ret < 0) { -- 2.56.1.915.g69d5ec7298-goog