Commit d5a8e4be authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'gpio-fixes-for-v7.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio fixes from Bartosz Golaszewski:

 - fix memory leaks in shared GPIO management

 - normalize the return values of gpio_chip::get() in GPIO core on
   behalf of drivers that return invalid values (this is done because
   adding stricter sanitization of callback retvals led to breakages in
   existing users, we'll revert that once all are fixed)

* tag 'gpio-fixes-for-v7.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
  gpiolib: normalize the return value of gc->get() on behalf of buggy drivers
  gpio: shared: fix memory leaks
parents bbcb2cd6 ec2ccead
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -748,14 +748,14 @@ static bool gpio_shared_entry_is_really_shared(struct gpio_shared_entry *entry)
static void gpio_shared_free_exclusive(void)
{
	struct gpio_shared_entry *entry, *epos;
	struct gpio_shared_ref *ref, *rpos;

	list_for_each_entry_safe(entry, epos, &gpio_shared_list, list) {
		if (gpio_shared_entry_is_really_shared(entry))
			continue;

		gpio_shared_drop_ref(list_first_entry(&entry->refs,
						      struct gpio_shared_ref,
						      list));
		list_for_each_entry_safe(ref, rpos, &entry->refs, list)
			gpio_shared_drop_ref(ref);
		gpio_shared_drop_entry(entry);
	}
}
+6 −2
Original line number Diff line number Diff line
@@ -3267,8 +3267,12 @@ static int gpiochip_get(struct gpio_chip *gc, unsigned int offset)

	/* Make sure this is called after checking for gc->get(). */
	ret = gc->get(gc, offset);
	if (ret > 1)
		ret = -EBADE;
	if (ret > 1) {
		gpiochip_warn(gc,
			"invalid return value from gc->get(): %d, consider fixing the driver\n",
			ret);
		ret = !!ret;
	}

	return ret;
}