提交 66401e71 编写于 作者: M Maxim Korotkov 提交者: zhaoxiaoqiang11

pinctrl: single: fix potential NULL dereference

stable inclusion
from stable-v5.10.168
commit 6e2a0521e4e84a2698f2da3950fb5c5496a4d208
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7URR4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6e2a0521e4e84a2698f2da3950fb5c5496a4d208

----------------------------------------------------

[ Upstream commit d2d73e6d ]

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: NMaxim Korotkov <korotkov.maxim.s@gmail.com>
Reviewed-by: NTony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20221118104332.943-1-korotkov.maxim.s@gmail.comSigned-off-by: NLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nzhaoxiaoqiang11 <zhaoxiaoqiang11@jd.com>
上级 1c41eb4a
...@@ -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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册