linux-kernel.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

* Re: [PATCH] pinctrl: single: fix potential NULL dereference
  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
  1 sibling, 1 reply; 4+ messages in thread
From: Tony Lindgren @ 2022-11-18 12:52 UTC (permalink / raw)
  To: Maxim Korotkov
  Cc: Haojian Zhuang, Linus Walleij, linux-arm-kernel, linux-omap,
	linux-gpio, linux-kernel, lvc-project

* Maxim Korotkov <korotkov.maxim.s@gmail.com> [221118 10:33]:
> 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.

Reviewed-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH] pinctrl: single: fix potential NULL dereference
  2022-11-18 12:52 ` Tony Lindgren
@ 2023-01-25  9:03   ` Maxim Korotkov
  0 siblings, 0 replies; 4+ messages in thread
From: Maxim Korotkov @ 2023-01-25  9:03 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Haojian Zhuang, linux-arm-kernel, linux-omap, linux-gpio,
	linux-kernel, lvc-project, Tony Lindgren

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

On 18.11.2022 15:52, Tony Lindgren wrote:
> * Maxim Korotkov <korotkov.maxim.s@gmail.com> [221118 10:33]:
>> 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.
> 
> Reviewed-by: Tony Lindgren <tony@atomide.com>

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

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

On Fri, Nov 18, 2022 at 11:43 AM Maxim Korotkov
<korotkov.maxim.s@gmail.com> wrote:

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

Patch applied for fixes.

Yours,
Linus Walleij

^ permalink raw reply	[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).