Skip to content

Commit d5a8e4b

Browse files
committed
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
2 parents bbcb2cd + ec2ccea commit d5a8e4b

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

drivers/gpio/gpiolib-shared.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -748,14 +748,14 @@ static bool gpio_shared_entry_is_really_shared(struct gpio_shared_entry *entry)
748748
static void gpio_shared_free_exclusive(void)
749749
{
750750
struct gpio_shared_entry *entry, *epos;
751+
struct gpio_shared_ref *ref, *rpos;
751752

752753
list_for_each_entry_safe(entry, epos, &gpio_shared_list, list) {
753754
if (gpio_shared_entry_is_really_shared(entry))
754755
continue;
755756

756-
gpio_shared_drop_ref(list_first_entry(&entry->refs,
757-
struct gpio_shared_ref,
758-
list));
757+
list_for_each_entry_safe(ref, rpos, &entry->refs, list)
758+
gpio_shared_drop_ref(ref);
759759
gpio_shared_drop_entry(entry);
760760
}
761761
}

drivers/gpio/gpiolib.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3267,8 +3267,12 @@ static int gpiochip_get(struct gpio_chip *gc, unsigned int offset)
32673267

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

32733277
return ret;
32743278
}

0 commit comments

Comments
 (0)