Commit ee68f18d authored by Tzung-Bi Shih's avatar Tzung-Bi Shih Committed by Bartosz Golaszewski
Browse files

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: default avatarLinus Walleij <linusw@kernel.org>
Signed-off-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
Link: https://patch.msgid.link/20260223061726.82161-6-tzungbi@kernel.org


Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
parent cf674f1a
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -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;