linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: single: fix potential NULL dereference
@ 2022-11-18 10:43 Maxim Korotkov
  2022-11-18 12:52 ` Tony Lindgren
  2023-01-27 12:44 ` Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: Maxim Korotkov @ 2022-11-18 10:43 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Maxim Korotkov, Haojian Zhuang, Linus Walleij, linux-arm-kernel,
	linux-omap, linux-gpio, linux-kernel, lvc-project

Added checking of pointer "function" in pcs_set_mux().
pinmux_generic_get_function() can return NULL and the pointer
"function" was dereferenced without checking against NULL.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 571aec4df5b7 ("pinctrl: single: Use generic pinmux helpers for managing functions")
Signed-off-by: Maxim Korotkov <korotkov.maxim.s@gmail.com>
---
 drivers/pinctrl/pinctrl-single.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 67bec7ea0f8b..5655a2da5413 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -372,6 +372,8 @@ static int pcs_set_mux(struct pinctrl_dev *pctldev, unsigned fselector,
 	if (!pcs->fmask)
 		return 0;
 	function = pinmux_generic_get_function(pctldev, fselector);
+	if (!function)
+		return -EINVAL;
 	func = function->data;
 	if (!func)
 		return -EINVAL;
-- 
2.17.1


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

end of thread, other threads:[~2023-01-27 12:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-18 10:43 [PATCH] pinctrl: single: fix potential NULL dereference Maxim Korotkov
2022-11-18 12:52 ` Tony Lindgren
2023-01-25  9:03   ` Maxim Korotkov
2023-01-27 12:44 ` 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).