[PATCH 2/2] gpio: remove obsolete UAF FIXMEs from lookup paths

From: Marco Scardovi (scardracs)

Date: Sun May 24 2026 - 12:28:38 EST


The ACPI and swnode GPIO lookup backends both temporarily grab a reference
to the gpio_device, resolve the descriptor, and then drop the reference
before returning the descriptor to the caller. They carry FIXME comments
warning that the descriptor is being returned without its backing device
reference.

However, the gpiod_find_and_request() core functionally prevents any
use-after-free window by wrapping the entire lookup operation inside the
gpio_devices_srcu read lock. The lookup functions are correct to drop
their references since the caller (gpiod_request) will subsequently take
its own permanent module and device references safely.

Remove these obsolete FIXMEs to prevent misleading future subsystem
developers.

Assisted-by: Antigravity:gemini-3.5-flash
Signed-off-by: Marco Scardovi <scardracs@xxxxxxxxxxx>
---
drivers/gpio/gpiolib-acpi-core.c | 4 ----
drivers/gpio/gpiolib-swnode.c | 4 ----
2 files changed, 8 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi-core.c b/drivers/gpio/gpiolib-acpi-core.c
index eb8a40cfb7a9..1a762a2988b7 100644
--- a/drivers/gpio/gpiolib-acpi-core.c
+++ b/drivers/gpio/gpiolib-acpi-core.c
@@ -142,10 +142,6 @@ static struct gpio_desc *acpi_get_gpiod(char *path, unsigned int pin)
if (!gdev)
return ERR_PTR(-EPROBE_DEFER);

- /*
- * FIXME: keep track of the reference to the GPIO device somehow
- * instead of putting it here.
- */
return gpio_device_get_desc(gdev, pin);
}

diff --git a/drivers/gpio/gpiolib-swnode.c b/drivers/gpio/gpiolib-swnode.c
index 4374067f621e..8d9591aa9304 100644
--- a/drivers/gpio/gpiolib-swnode.c
+++ b/drivers/gpio/gpiolib-swnode.c
@@ -114,10 +114,6 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode,
if (IS_ERR(gdev))
return ERR_CAST(gdev);

- /*
- * FIXME: The GPIO device reference is put at return but the descriptor
- * is passed on. Find a proper solution.
- */
desc = gpio_device_get_desc(gdev, args.args[0]);
*flags = args.args[1]; /* We expect native GPIO flags */

--
2.54.0