Skip to contentSkip to conversation

pinctrl: single: fix potential NULL dereference

PATCH In review Maxim Korotkov 3 participants 4 messages Nov 18, 2022 – Jan 27, 2023

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

PATCH 1/1 pinctrl: single: fix potential NULL dereference

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")
---
 drivers/pinctrl/pinctrl-single.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pinctrl/pinctrl-single.c +2 -0
index 67bec7ea0f8b..5655a2da5413 100644
@@ -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;
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Maxim Korotkov

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.

#2 lore raw

Dear Linus,
Will this patch be applied or rejected?
best regards, Max

Quoted 6 lines · Tony Lindgren
Quoted 3 lines · Maxim Korotkov

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.

#3 lore raw
In reply to Maxim Korotkov
Quoted 8 lines · Maxim Korotkov

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

Patch applied for fixes.

Yours,
Linus Walleij