linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: pinmux: fix a possible null pointer in pinmux_can_be_used_for_gpio
@ 2019-12-04 14:41 Alexandre Torgue
  2019-12-13  9:57 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Alexandre Torgue @ 2019-12-04 14:41 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-kernel, linux-gpio, linux-stm32, alexandre.torgue, Stefan Wahren

This commit adds a check on ops pointer to avoid a kernel panic when
ops->strict is used. Indeed, on some pinctrl driver (at least for
pinctrl-stmfx) the pinmux ops is not implemented. Let's assume than gpio
can be used in this case.

Fixes: 472a61e777fe ("pinctrl/gpio: Take MUX usage into account")

Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>

diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index e914f6efd39e..9503ddf2edc7 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -85,7 +85,7 @@ bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned pin)
 	const struct pinmux_ops *ops = pctldev->desc->pmxops;
 
 	/* Can't inspect pin, assume it can be used */
-	if (!desc)
+	if (!desc || !ops)
 		return true;
 
 	if (ops->strict && desc->mux_usecount)
-- 
2.17.1


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

* Re: [PATCH] pinctrl: pinmux: fix a possible null pointer in pinmux_can_be_used_for_gpio
  2019-12-04 14:41 [PATCH] pinctrl: pinmux: fix a possible null pointer in pinmux_can_be_used_for_gpio Alexandre Torgue
@ 2019-12-13  9:57 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2019-12-13  9:57 UTC (permalink / raw)
  To: Alexandre Torgue
  Cc: linux-kernel, open list:GPIO SUBSYSTEM, linux-stm32, Stefan Wahren

On Wed, Dec 4, 2019 at 3:41 PM Alexandre Torgue <alexandre.torgue@st.com> wrote:

> This commit adds a check on ops pointer to avoid a kernel panic when
> ops->strict is used. Indeed, on some pinctrl driver (at least for
> pinctrl-stmfx) the pinmux ops is not implemented. Let's assume than gpio
> can be used in this case.
>
> Fixes: 472a61e777fe ("pinctrl/gpio: Take MUX usage into account")
> Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>

Patch applied for fixes.

Yours,
Linus Walleij

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

end of thread, other threads:[~2019-12-13  9:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-04 14:41 [PATCH] pinctrl: pinmux: fix a possible null pointer in pinmux_can_be_used_for_gpio Alexandre Torgue
2019-12-13  9:57 ` 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).