Commit d2d73e6d authored by Maxim Korotkov's avatar Maxim Korotkov Committed by Linus Walleij

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: 571aec4d ("pinctrl: single: Use generic pinmux helpers for managing functions")
Signed-off-by: default avatarMaxim Korotkov <korotkov.maxim.s@gmail.com>
Reviewed-by: default avatarTony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20221118104332.943-1-korotkov.maxim.s@gmail.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent c6e0679b
...@@ -372,6 +372,8 @@ static int pcs_set_mux(struct pinctrl_dev *pctldev, unsigned fselector, ...@@ -372,6 +372,8 @@ static int pcs_set_mux(struct pinctrl_dev *pctldev, unsigned fselector,
if (!pcs->fmask) if (!pcs->fmask)
return 0; return 0;
function = pinmux_generic_get_function(pctldev, fselector); function = pinmux_generic_get_function(pctldev, fselector);
if (!function)
return -EINVAL;
func = function->data; func = function->data;
if (!func) if (!func)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment