Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'gpio-fixes-for-v6.5-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio fixes from Bartosz Golaszewski:

- fix a regression in the sysfs interface

- fix a reference counting bug that's been around for years

- MAINTAINERS update

* tag 'gpio-fixes-for-v6.5-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
gpiolib: fix reference leaks when removing GPIO chips still in use
gpiolib: sysfs: Do unexport GPIO when user asks for it
MAINTAINERS: add content regex for gpio-regmap

+17 -7
+1
MAINTAINERS
··· 8812 8812 S: Maintained 8813 8813 F: drivers/gpio/gpio-regmap.c 8814 8814 F: include/linux/gpio/regmap.h 8815 + K: (devm_)?gpio_regmap_(un)?register 8815 8816 8816 8817 GPIO SUBSYSTEM 8817 8818 M: Linus Walleij <linus.walleij@linaro.org>
+5 -2
drivers/gpio/gpiolib-sysfs.c
··· 515 515 * they may be undone on its behalf too. 516 516 */ 517 517 if (test_and_clear_bit(FLAG_SYSFS, &desc->flags)) { 518 - status = 0; 518 + gpiod_unexport(desc); 519 519 gpiod_free(desc); 520 + status = 0; 520 521 } 521 522 done: 522 523 if (status) ··· 782 781 mutex_unlock(&sysfs_lock); 783 782 784 783 /* unregister gpiod class devices owned by sysfs */ 785 - for_each_gpio_desc_with_flag(chip, desc, FLAG_SYSFS) 784 + for_each_gpio_desc_with_flag(chip, desc, FLAG_SYSFS) { 785 + gpiod_unexport(desc); 786 786 gpiod_free(desc); 787 + } 787 788 } 788 789 789 790 static int __init gpiolib_sysfs_init(void)
+11 -5
drivers/gpio/gpiolib.c
··· 2167 2167 2168 2168 void gpiod_free(struct gpio_desc *desc) 2169 2169 { 2170 - if (desc && desc->gdev && gpiod_free_commit(desc)) { 2171 - module_put(desc->gdev->owner); 2172 - gpio_device_put(desc->gdev); 2173 - } else { 2170 + /* 2171 + * We must not use VALIDATE_DESC_VOID() as the underlying gdev->chip 2172 + * may already be NULL but we still want to put the references. 2173 + */ 2174 + if (!desc) 2175 + return; 2176 + 2177 + if (!gpiod_free_commit(desc)) 2174 2178 WARN_ON(extra_checks); 2175 - } 2179 + 2180 + module_put(desc->gdev->owner); 2181 + gpio_device_put(desc->gdev); 2176 2182 } 2177 2183 2178 2184 /**