]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
pinctrl: single: fix potential NULL dereference in pcs_get_function()
authorMa Ke <make24@iscas.ac.cn>
Thu, 8 Aug 2024 04:13:55 +0000 (12:13 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Sep 2024 11:17:44 +0000 (13:17 +0200)
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: 571aec4df5b7 ("pinctrl: single: Use generic pinmux helpers for managing functions")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Link: https://lore.kernel.org/20240808041355.2766009-1-make24@iscas.ac.cn
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pinctrl/pinctrl-single.c

index 4860c4dd853f33a7c0f6c91252d51be97a27ae8d..5b76594b535c1a034f801ba0d5d6e4237b2929ce 100644 (file)
@@ -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",