Skip to contentSkip to conversation

pinctrl: pinmux: fix a possible null pointer in pinmux_can_be_used_for_gpio

PATCH In review Alexandre Torgue 2 participants 2 messages Dec 4, 2019 – Dec 13, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: pinmux: fix a possible null pointer in pinmux_can_be_used_for_gpio

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")
drivers/pinctrl/pinmux.c +1 -1
index e914f6efd39e..9503ddf2edc7 100644
@@ -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)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 7 lines · Alexandre Torgue

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

Patch applied for fixes.

Yours,
Linus Walleij