pinctrl: pinmux: fix a possible null pointer in pinmux_can_be_used_for_gpio
diff mbox series

Message ID 20191204144106.10876-1-alexandre.torgue@st.com
State New
Headers show
Series
  • pinctrl: pinmux: fix a possible null pointer in pinmux_can_be_used_for_gpio
Related show

Commit Message

Alexandre Torgue Dec. 4, 2019, 2:41 p.m. UTC
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>

Comments

Linus Walleij Dec. 13, 2019, 9:57 a.m. UTC | #1
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

Patch
diff mbox series

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)