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

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
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8812,6 +8812,7 @@ R: Michael Walle <michael@walle.cc>
S:	Maintained
F:	drivers/gpio/gpio-regmap.c
F:	include/linux/gpio/regmap.h
K:	(devm_)?gpio_regmap_(un)?register
GPIO SUBSYSTEM
M:	Linus Walleij <linus.walleij@linaro.org>
+5 −2
Original line number Diff line number Diff line
@@ -515,8 +515,9 @@ static ssize_t unexport_store(const struct class *class,
	 * they may be undone on its behalf too.
	 */
	if (test_and_clear_bit(FLAG_SYSFS, &desc->flags)) {
		status = 0;
		gpiod_unexport(desc);
		gpiod_free(desc);
		status = 0;
	}
done:
	if (status)
@@ -781,9 +782,11 @@ void gpiochip_sysfs_unregister(struct gpio_device *gdev)
	mutex_unlock(&sysfs_lock);

	/* 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);
	}
}

static int __init gpiolib_sysfs_init(void)
{
+11 −5
Original line number Diff line number Diff line
@@ -2167,12 +2167,18 @@ static bool gpiod_free_commit(struct gpio_desc *desc)

void gpiod_free(struct gpio_desc *desc)
{
	if (desc && desc->gdev && gpiod_free_commit(desc)) {
	/*
	 * We must not use VALIDATE_DESC_VOID() as the underlying gdev->chip
	 * may already be NULL but we still want to put the references.
	 */
	if (!desc)
		return;

	if (!gpiod_free_commit(desc))
		WARN_ON(extra_checks);

	module_put(desc->gdev->owner);
	gpio_device_put(desc->gdev);
	} else {
		WARN_ON(extra_checks);
	}
}

/**