Skip to content

Commit

Permalink
pinctrl: core: Warn about NULL gpio_chip in pinctrl_ready_for_gpio_ra…
Browse files Browse the repository at this point in the history
…nge()

If the gpio driver is confused about the numbers for gpio-ranges,
pinctrl_ready_for_gpio_range() may get called with invalid GPIO
causing a NULL pointer exception. Let's instead provide a warning
that allows fixing the problem and return with error.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Tony Lindgren authored and Linus Walleij committed Sep 14, 2015
1 parent 163dc9f commit 942cde7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/pinctrl/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ static bool pinctrl_ready_for_gpio_range(unsigned gpio)
struct pinctrl_gpio_range *range = NULL;
struct gpio_chip *chip = gpio_to_chip(gpio);

if (WARN(!chip, "no gpio_chip for gpio%i?", gpio))
return false;

mutex_lock(&pinctrldev_list_mutex);

/* Loop over the pin controllers */
Expand Down

0 comments on commit 942cde7

Please sign in to comment.