Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [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

end of thread, other threads:[~2026-12-03 11:31 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  7:11   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox