From: Tzung-Bi Shih Date: Mon, 23 Feb 2026 06:17:25 +0000 (+0800) Subject: gpio: cdev: Don't check struct gpio_chip in gpio_chrdev_open() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee68f18d1f0d943d93070eb8cb05598b8b7f0922;p=thirdparty%2Fkernel%2Flinux.git gpio: cdev: Don't check struct gpio_chip in gpio_chrdev_open() 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 Signed-off-by: Tzung-Bi Shih Link: https://patch.msgid.link/20260223061726.82161-6-tzungbi@kernel.org Signed-off-by: Bartosz Golaszewski --- diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index 58a6e9a6ec62d..7ebdb4993a74a 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -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;