]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gpio: cdev: Don't check struct gpio_chip in gpio_chrdev_open()
authorTzung-Bi Shih <tzungbi@kernel.org>
Mon, 23 Feb 2026 06:17:25 +0000 (14:17 +0800)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Fri, 27 Feb 2026 09:05:21 +0000 (10:05 +0100)
It's harmless even if: chrdev_open() and cdev_device_del() run at the
same time, and gpio_chrdev_open() gets called after the underlying GPIO
chip has gone.  The subsequent file operations check the availability
of struct gpio_chip anyway.

Don't check struct gpio_chip in gpio_chrdev_open().

Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://patch.msgid.link/20260223061726.82161-6-tzungbi@kernel.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
drivers/gpio/gpiolib-cdev.c

index 58a6e9a6ec62de85288e62d9179b82eb69ee0e65..7ebdb4993a74a7620dcd2b0206f6e8b0e5972290 100644 (file)
@@ -2640,12 +2640,6 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file)
        struct gpio_chardev_data *cdev;
        int ret = -ENOMEM;
 
-       guard(srcu)(&gdev->srcu);
-
-       /* Fail on open if the backing gpiochip is gone */
-       if (!rcu_access_pointer(gdev->chip))
-               return -ENODEV;
-
        cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
        if (!cdev)
                return -ENOMEM;