* [PATCH 0/6] gpio: fix firmware node reference count underflows
@ 2026-12-03 6:45 Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 1/6] gpio: arizona: Fix firmware node reference count underflow Dmitry Torokhov
` (5 more replies)
0 siblings, 6 replies; 10+ 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
Several GPIO platform drivers attach a parent MFD or underlying protocol
device's firmware node to their own platform device using
device_set_node() without taking a reference. On platform device
teardown, platform_device_release() drops a firmware node reference and
removes any attached software node, underflowing the parent or protocol
device's reference count and prematurely tearing down an attached
software node.
Assigning gpio_chip.fwnode avoids mutating a registered platform device
during probe. Calling device_set_node() with fwnode_handle_get() leaks a
reference on re-probe (unbind/rebind, module reload, or deferred or
failed probe). Using platform_device_set_fwnode() (introduced in commit
8877c06885ce) triggers a WARN_ON() when a secondary or software firmware
node is already attached (such as an ACPI MFD parent with a secondary
software node, or any re-probe on a software-node parent) and does not
exist in older stable kernels. Taking a reference on a shared primary
node alone also does not prevent device_remove_software_node() during
platform_device_release() from detaching and putting a shared secondary
software node on kernels lacking a shared-primary driver core fix.
Commit 6dbe6c07f94f replaced gpio_chip.of_node one week before
gpio_chip.fwnode was added in commit 990f6756bb64, making
gpio_chip.fwnode the direct mechanism for passing a firmware node to
gpiolib. Leaving the platform device's of_node unset also keeps its
uevent MODALIAS as platform:<name> and avoids pinctrl_bind_pins()
conflicts on rebind.
Update arizona, tps6586x, tps65910, twl6040, and wm831x GPIO drivers to
pass the firmware node directly via gpio_chip.fwnode while keeping the
platform device as gpio_chip.parent, since MFD core already propagates
any parent ACPI companion to those direct children. Because cros-ec
sits behind an intermediate cros-ec-dev device that does not propagate
an ACPI companion, set gpio_chip.fwnode explicitly in cros-ec and keep
attaching the protocol device's firmware node with a devres-managed
reference cleared on unbind to preserve acpi_gpiochip_add() behavior.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Dmitry Torokhov (6):
gpio: arizona: Fix firmware node reference count underflow
gpio: tps6586x: Fix firmware node reference count underflow
gpio: tps65910: Fix firmware node reference count underflow
gpio: twl6040: Fix firmware node reference count underflow
gpio: wm831x: Fix firmware node reference count underflow
gpio: cros-ec: Fix firmware node reference count underflow
drivers/gpio/gpio-arizona.c | 3 +--
drivers/gpio/gpio-cros-ec.c | 26 ++++++++++++++++++++++++--
drivers/gpio/gpio-tps6586x.c | 3 +--
drivers/gpio/gpio-tps65910.c | 3 +--
drivers/gpio/gpio-twl6040.c | 3 +--
drivers/gpio/gpio-wm831x.c | 3 +--
6 files changed, 29 insertions(+), 12 deletions(-)
---
base-commit: 799dd936553182df5770dde7f38d94c8337df75a
change-id: 20261202-gpio-arizona-fwnode-fix-1b8e7d9610fb
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 10+ messages in thread
* [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; 10+ 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] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ 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
2026-12-03 12:11 ` Andy Shevchenko
5 siblings, 1 reply; 10+ 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] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ messages in thread
* Re: [PATCH 6/6] gpio: cros-ec: Fix firmware node reference count underflow
2026-12-03 6:45 ` [PATCH 6/6] gpio: cros-ec: " Dmitry Torokhov
@ 2026-12-03 12:11 ` Andy Shevchenko
0 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2026-12-03 12:11 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Linus Walleij, Bartosz Golaszewski, Benson Leung, Guenter Roeck,
Stephen Boyd, patches, linux-gpio, chrome-platform, stable
On Wed, Dec 02, 2026 at 10:45:51PM -0800, Dmitry Torokhov wrote:
> 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.
...
> + ret = devm_add_action_or_reset(dev, cros_ec_gpio_put_fwnode,
> + dev);
Don't hesitate in such a case to use longer line.
ret = devm_add_action_or_reset(dev, cros_ec_gpio_put_fwnode, dev);
is only 2 characters longer than 80. It's allowed in order to improve
readability.
> + if (ret)
> + return ret;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-12-03 12:12 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 11:28 ` Charles Keepax
2026-12-03 6:45 ` [PATCH 2/6] gpio: tps6586x: " Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 3/6] gpio: tps65910: " Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 4/6] gpio: twl6040: " Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 5/6] gpio: wm831x: " Dmitry Torokhov
2026-12-03 11:28 ` Charles Keepax
2026-12-03 6:45 ` [PATCH 6/6] gpio: cros-ec: " Dmitry Torokhov
2026-12-03 12:11 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox