* [PATCH 1/6] gpio: arizona: Fix firmware node reference count underflow
2026-12-03 6:45 [PATCH 0/6] gpio: fix firmware node reference count underflows Dmitry Torokhov
@ 2026-12-03 6:45 ` Dmitry Torokhov
2026-12-03 11:28 ` Charles Keepax
2026-12-03 6:45 ` [PATCH 2/6] gpio: tps6586x: " Dmitry Torokhov
` (4 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Dmitry Torokhov @ 2026-12-03 6:45 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Benson Leung,
Guenter Roeck, Stephen Boyd
Cc: patches, linux-gpio, chrome-platform, stable
arizona_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 for runtime
PM. 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 <dmitry.torokhov@gmail.com>
---
drivers/gpio/gpio-arizona.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-arizona.c b/drivers/gpio/gpio-arizona.c
index 5a6182ad804b..a84360014a16 100644
--- a/drivers/gpio/gpio-arizona.c
+++ b/drivers/gpio/gpio-arizona.c
@@ -153,8 +153,6 @@ static int arizona_gpio_probe(struct platform_device *pdev)
struct arizona_gpio *arizona_gpio;
int ret;
- device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent));
-
arizona_gpio = devm_kzalloc_obj(&pdev->dev, *arizona_gpio);
if (!arizona_gpio)
return -ENOMEM;
@@ -162,6 +160,7 @@ static int arizona_gpio_probe(struct platform_device *pdev)
arizona_gpio->arizona = arizona;
arizona_gpio->gpio_chip = template_chip;
arizona_gpio->gpio_chip.parent = &pdev->dev;
+ arizona_gpio->gpio_chip.fwnode = dev_fwnode(pdev->dev.parent);
switch (arizona->type) {
case WM5102:
--
2.56.1.915.g69d5ec7298-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 1/6] gpio: arizona: Fix firmware node reference count underflow
2026-12-03 6:45 ` [PATCH 1/6] gpio: arizona: Fix firmware node reference count underflow Dmitry Torokhov
@ 2026-12-03 11:28 ` Charles Keepax
0 siblings, 0 replies; 9+ messages in thread
From: Charles Keepax @ 2026-12-03 11:28 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Benson Leung,
Guenter Roeck, Stephen Boyd, patches, linux-gpio, chrome-platform,
stable
On Wed, Dec 02, 2026 at 10:45:46PM -0800, Dmitry Torokhov wrote:
> arizona_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 for runtime
> PM. 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 <dmitry.torokhov@gmail.com>
> ---
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Thanks,
Charles
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/6] gpio: tps6586x: Fix firmware node reference count underflow
2026-12-03 6:45 [PATCH 0/6] gpio: fix firmware node reference count underflows Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 1/6] gpio: arizona: Fix firmware node reference count underflow Dmitry Torokhov
@ 2026-12-03 6:45 ` Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 3/6] gpio: tps65910: " Dmitry Torokhov
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2026-12-03 6:45 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Benson Leung,
Guenter Roeck, Stephen Boyd
Cc: patches, linux-gpio, chrome-platform, stable
tps6586x_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 <dmitry.torokhov@gmail.com>
---
drivers/gpio/gpio-tps6586x.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-tps6586x.c b/drivers/gpio/gpio-tps6586x.c
index 072557390cb2..cd2d13ac20db 100644
--- a/drivers/gpio/gpio-tps6586x.c
+++ b/drivers/gpio/gpio-tps6586x.c
@@ -80,8 +80,6 @@ static int tps6586x_gpio_probe(struct platform_device *pdev)
struct tps6586x_platform_data *pdata;
struct tps6586x_gpio *tps6586x_gpio;
- device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent));
-
pdata = dev_get_platdata(pdev->dev.parent);
tps6586x_gpio = devm_kzalloc_obj(&pdev->dev, *tps6586x_gpio);
if (!tps6586x_gpio)
@@ -92,6 +90,7 @@ static int tps6586x_gpio_probe(struct platform_device *pdev)
tps6586x_gpio->gpio_chip.owner = THIS_MODULE;
tps6586x_gpio->gpio_chip.label = pdev->name;
tps6586x_gpio->gpio_chip.parent = &pdev->dev;
+ tps6586x_gpio->gpio_chip.fwnode = dev_fwnode(pdev->dev.parent);
tps6586x_gpio->gpio_chip.ngpio = 4;
tps6586x_gpio->gpio_chip.can_sleep = true;
--
2.56.1.915.g69d5ec7298-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 3/6] gpio: tps65910: Fix firmware node reference count underflow
2026-12-03 6:45 [PATCH 0/6] gpio: fix firmware node reference count underflows Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 1/6] gpio: arizona: Fix firmware node reference count underflow Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 2/6] gpio: tps6586x: " Dmitry Torokhov
@ 2026-12-03 6:45 ` Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 4/6] gpio: twl6040: " Dmitry Torokhov
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2026-12-03 6:45 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Benson Leung,
Guenter Roeck, Stephen Boyd
Cc: patches, linux-gpio, chrome-platform, stable
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 <dmitry.torokhov@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 4/6] gpio: twl6040: Fix firmware node reference count underflow
2026-12-03 6:45 [PATCH 0/6] gpio: fix firmware node reference count underflows Dmitry Torokhov
` (2 preceding siblings ...)
2026-12-03 6:45 ` [PATCH 3/6] gpio: tps65910: " Dmitry Torokhov
@ 2026-12-03 6:45 ` Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 5/6] gpio: wm831x: " Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 6/6] gpio: cros-ec: " Dmitry Torokhov
5 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2026-12-03 6:45 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Benson Leung,
Guenter Roeck, Stephen Boyd
Cc: patches, linux-gpio, chrome-platform, stable
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 <dmitry.torokhov@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 5/6] gpio: wm831x: Fix firmware node reference count underflow
2026-12-03 6:45 [PATCH 0/6] gpio: fix firmware node reference count underflows Dmitry Torokhov
` (3 preceding siblings ...)
2026-12-03 6:45 ` [PATCH 4/6] gpio: twl6040: " Dmitry Torokhov
@ 2026-12-03 6:45 ` Dmitry Torokhov
2026-12-03 11:28 ` Charles Keepax
2026-12-03 6:45 ` [PATCH 6/6] gpio: cros-ec: " Dmitry Torokhov
5 siblings, 1 reply; 9+ messages in thread
From: Dmitry Torokhov @ 2026-12-03 6:45 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Benson Leung,
Guenter Roeck, Stephen Boyd
Cc: patches, linux-gpio, chrome-platform, stable
wm831x_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 <dmitry.torokhov@gmail.com>
---
drivers/gpio/gpio-wm831x.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-wm831x.c b/drivers/gpio/gpio-wm831x.c
index 8bc406510a0a..730a2c05f301 100644
--- a/drivers/gpio/gpio-wm831x.c
+++ b/drivers/gpio/gpio-wm831x.c
@@ -265,8 +265,6 @@ static int wm831x_gpio_probe(struct platform_device *pdev)
struct wm831x_pdata *pdata = &wm831x->pdata;
struct wm831x_gpio *wm831x_gpio;
- device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent));
-
wm831x_gpio = devm_kzalloc_obj(&pdev->dev, *wm831x_gpio);
if (wm831x_gpio == NULL)
return -ENOMEM;
@@ -275,6 +273,7 @@ static int wm831x_gpio_probe(struct platform_device *pdev)
wm831x_gpio->gpio_chip = template_chip;
wm831x_gpio->gpio_chip.ngpio = wm831x->num_gpio;
wm831x_gpio->gpio_chip.parent = &pdev->dev;
+ wm831x_gpio->gpio_chip.fwnode = dev_fwnode(pdev->dev.parent);
if (pdata && pdata->gpio_base)
wm831x_gpio->gpio_chip.base = pdata->gpio_base;
else
--
2.56.1.915.g69d5ec7298-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 5/6] gpio: wm831x: Fix firmware node reference count underflow
2026-12-03 6:45 ` [PATCH 5/6] gpio: wm831x: " Dmitry Torokhov
@ 2026-12-03 11:28 ` Charles Keepax
0 siblings, 0 replies; 9+ messages in thread
From: Charles Keepax @ 2026-12-03 11:28 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Benson Leung,
Guenter Roeck, Stephen Boyd, patches, linux-gpio, chrome-platform,
stable
On Wed, Dec 02, 2026 at 10:45:50PM -0800, Dmitry Torokhov wrote:
> wm831x_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 <dmitry.torokhov@gmail.com>
> ---
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Thanks,
Charles
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 6/6] gpio: cros-ec: Fix firmware node reference count underflow
2026-12-03 6:45 [PATCH 0/6] gpio: fix firmware node reference count underflows Dmitry Torokhov
` (4 preceding siblings ...)
2026-12-03 6:45 ` [PATCH 5/6] gpio: wm831x: " Dmitry Torokhov
@ 2026-12-03 6:45 ` Dmitry Torokhov
5 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2026-12-03 6:45 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Benson Leung,
Guenter Roeck, Stephen Boyd
Cc: patches, linux-gpio, chrome-platform, stable
cros_ec_gpio_probe() attaches the underlying EC protocol 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 protocol device's reference count and prematurely
tearing down an attached software node.
Take a reference with fwnode_handle_get() when attaching the protocol
device's firmware node if the platform device does not already have one,
and register cros_ec_gpio_put_fwnode() via devm_add_action_or_reset()
before devm_gpiochip_add_data() to clear the platform device's node and
drop the reference. Because devres runs in LIFO order, the GPIO chip and
acpi_gpiochip_remove() on the parent device finish before the node is
cleared, and device_del() unbinds the driver before
device_platform_notify_remove() and platform_device_release().
This preserves ACPI companion attachment for acpi_gpiochip_add(), which
inspects the parent device while cros-ec-dev does not propagate it,
while gpio_chip.fwnode is also assigned explicitly.
Fixes: f837fe1bffe6 ("gpio: Add ChromeOS EC GPIO driver")
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/gpio/gpio-cros-ec.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-cros-ec.c b/drivers/gpio/gpio-cros-ec.c
index d06d74bd86d8..4a77ff3acd54 100644
--- a/drivers/gpio/gpio-cros-ec.c
+++ b/drivers/gpio/gpio-cros-ec.c
@@ -155,18 +155,39 @@ static int cros_ec_gpio_ngpios(struct cros_ec_device *cros_ec)
return response.get_count.val;
}
+static void cros_ec_gpio_put_fwnode(void *data)
+{
+ struct device *dev = data;
+ struct fwnode_handle *fwnode = dev_fwnode(dev);
+
+ device_set_node(dev, NULL);
+ fwnode_handle_put(fwnode);
+}
+
static int cros_ec_gpio_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device *parent = dev->parent;
struct cros_ec_dev *ec_dev = dev_get_drvdata(parent);
struct cros_ec_device *cros_ec = ec_dev->ec_dev;
+ struct fwnode_handle *fwnode = dev_fwnode(cros_ec->dev);
struct gpio_chip *gc;
int ngpios;
int ret;
- /* Use the fwnode from the protocol device, e.g. cros-ec-spi */
- device_set_node(dev, dev_fwnode(cros_ec->dev));
+ if (!dev_fwnode(dev) && fwnode) {
+ /*
+ * Use the fwnode from the protocol device, e.g. cros-ec-spi,
+ * so acpi_gpiochip_add() sees its ACPI companion. Clear it on
+ * unbind so platform_device_release() does not drop a parent
+ * reference or tear down a shared software node.
+ */
+ device_set_node(dev, fwnode_handle_get(fwnode));
+ ret = devm_add_action_or_reset(dev, cros_ec_gpio_put_fwnode,
+ dev);
+ if (ret)
+ return ret;
+ }
ngpios = cros_ec_gpio_ngpios(cros_ec);
if (ngpios < 0) {
@@ -180,6 +201,7 @@ static int cros_ec_gpio_probe(struct platform_device *pdev)
gc->ngpio = ngpios;
gc->parent = dev;
+ gc->fwnode = fwnode;
ret = cros_ec_gpio_init_names(cros_ec, gc);
if (ret)
return ret;
--
2.56.1.915.g69d5ec7298-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread