Commit 3e13eee1 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 8abd7287 3386fb86
...@@ -8812,6 +8812,7 @@ R: Michael Walle <michael@walle.cc> ...@@ -8812,6 +8812,7 @@ R: Michael Walle <michael@walle.cc>
S: Maintained S: Maintained
F: drivers/gpio/gpio-regmap.c F: drivers/gpio/gpio-regmap.c
F: include/linux/gpio/regmap.h F: include/linux/gpio/regmap.h
K: (devm_)?gpio_regmap_(un)?register
GPIO SUBSYSTEM GPIO SUBSYSTEM
M: Linus Walleij <linus.walleij@linaro.org> M: Linus Walleij <linus.walleij@linaro.org>
......
...@@ -515,8 +515,9 @@ static ssize_t unexport_store(const struct class *class, ...@@ -515,8 +515,9 @@ static ssize_t unexport_store(const struct class *class,
* they may be undone on its behalf too. * they may be undone on its behalf too.
*/ */
if (test_and_clear_bit(FLAG_SYSFS, &desc->flags)) { if (test_and_clear_bit(FLAG_SYSFS, &desc->flags)) {
status = 0; gpiod_unexport(desc);
gpiod_free(desc); gpiod_free(desc);
status = 0;
} }
done: done:
if (status) if (status)
...@@ -781,8 +782,10 @@ void gpiochip_sysfs_unregister(struct gpio_device *gdev) ...@@ -781,8 +782,10 @@ void gpiochip_sysfs_unregister(struct gpio_device *gdev)
mutex_unlock(&sysfs_lock); mutex_unlock(&sysfs_lock);
/* unregister gpiod class devices owned by sysfs */ /* unregister gpiod class devices owned by sysfs */
for_each_gpio_desc_with_flag(chip, desc, FLAG_SYSFS) for_each_gpio_desc_with_flag(chip, desc, FLAG_SYSFS) {
gpiod_unexport(desc);
gpiod_free(desc); gpiod_free(desc);
}
} }
static int __init gpiolib_sysfs_init(void) static int __init gpiolib_sysfs_init(void)
......
...@@ -2167,12 +2167,18 @@ static bool gpiod_free_commit(struct gpio_desc *desc) ...@@ -2167,12 +2167,18 @@ static bool gpiod_free_commit(struct gpio_desc *desc)
void gpiod_free(struct gpio_desc *desc) void gpiod_free(struct gpio_desc *desc)
{ {
if (desc && desc->gdev && gpiod_free_commit(desc)) { /*
module_put(desc->gdev->owner); * We must not use VALIDATE_DESC_VOID() as the underlying gdev->chip
gpio_device_put(desc->gdev); * may already be NULL but we still want to put the references.
} else { */
if (!desc)
return;
if (!gpiod_free_commit(desc))
WARN_ON(extra_checks); WARN_ON(extra_checks);
}
module_put(desc->gdev->owner);
gpio_device_put(desc->gdev);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment