Commit 3b30a36e authored by Ma Ke's avatar Ma Ke Committed by Zhang Zekun
Browse files

pinctrl: single: fix potential NULL dereference in pcs_get_function()

stable inclusion
from stable-v5.10.225
commit 4e9436375fcc9bd2a60ee96aba6ed53f7a377d10
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAR49K
CVE: CVE-2024-46685

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



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

commit 1c38a62f15e595346a1106025722869e87ffe044 upstream.

pinmux_generic_get_function() can return NULL and the pointer 'function'
was dereferenced without checking against NULL. Add checking of pointer
'function' in pcs_get_function().

Found by code review.

Cc: stable@vger.kernel.org
Fixes: 571aec4d ("pinctrl: single: Use generic pinmux helpers for managing functions")
Signed-off-by: default avatarMa Ke <make24@iscas.ac.cn>
Link: https://lore.kernel.org/20240808041355.2766009-1-make24@iscas.ac.cn


Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarZhang Zekun <zhangzekun11@huawei.com>
parent a234e031
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -350,6 +350,8 @@ static int pcs_get_function(struct pinctrl_dev *pctldev, unsigned pin,
		return -ENOTSUPP;
	fselector = setting->func;
	function = pinmux_generic_get_function(pctldev, fselector);
	if (!function)
		return -EINVAL;
	*func = function->data;
	if (!(*func)) {
		dev_err(pcs->dev, "%s could not find function%i\n",