]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gpio: remove obsolete UAF FIXMEs from lookup paths
authorMarco Scardovi (scardracs) <scardracs@disroot.org>
Sun, 24 May 2026 16:27:08 +0000 (18:27 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Thu, 4 Jun 2026 13:51:31 +0000 (15:51 +0200)
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@disroot.org>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260524162708.62949-3-scardracs@disroot.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
drivers/gpio/gpiolib-acpi-core.c
drivers/gpio/gpiolib-swnode.c

index 09f860200a059b1d17c652b9aa66a49abea3cb4f..fbd6945726bf8942049639d21c1b0a184406fee2 100644 (file)
@@ -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);
 }
 
index 4374067f621ed782a7e1549f7b0b7e44eac04930..8d9591aa9304d1eac931d1cb19597ae4b99c40a2 100644 (file)
@@ -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 */