tps65910_gpio_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-tps65910.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-tps65910.c b/drivers/gpio/gpio-tps65910.c index 884ef70a1301..ca12035f452b 100644 --- a/drivers/gpio/gpio-tps65910.c +++ b/drivers/gpio/gpio-tps65910.c @@ -114,8 +114,6 @@ static int tps65910_gpio_probe(struct platform_device *pdev) int ret; int i; - device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent)); - tps65910_gpio = devm_kzalloc_obj(&pdev->dev, *tps65910_gpio); if (!tps65910_gpio) return -ENOMEM; @@ -141,6 +139,7 @@ static int tps65910_gpio_probe(struct platform_device *pdev) tps65910_gpio->gpio_chip.set = tps65910_gpio_set; tps65910_gpio->gpio_chip.get = tps65910_gpio_get; tps65910_gpio->gpio_chip.parent = &pdev->dev; + tps65910_gpio->gpio_chip.fwnode = dev_fwnode(pdev->dev.parent); if (pdata && pdata->gpio_base) tps65910_gpio->gpio_chip.base = pdata->gpio_base; -- 2.56.1.915.g69d5ec7298-goog