linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: core: Warn about NULL gpio_chip in pinctrl_ready_for_gpio_range()
@ 2015-09-03 17:34 Tony Lindgren
  2015-09-08 14:11 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Tony Lindgren @ 2015-09-03 17:34 UTC (permalink / raw)
  To: linux-arm-kernel

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>
---
 drivers/pinctrl/core.c | 3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -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 */
-- 
2.1.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] pinctrl: core: Warn about NULL gpio_chip in pinctrl_ready_for_gpio_range()
  2015-09-03 17:34 [PATCH] pinctrl: core: Warn about NULL gpio_chip in pinctrl_ready_for_gpio_range() Tony Lindgren
@ 2015-09-08 14:11 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2015-09-08 14:11 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 3, 2015 at 7:34 PM, Tony Lindgren <tony@atomide.com> wrote:

> 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>

Patch applied for fixes.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-08 14:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-03 17:34 [PATCH] pinctrl: core: Warn about NULL gpio_chip in pinctrl_ready_for_gpio_range() Tony Lindgren
2015-09-08 14:11 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).