Skip to content

Commit 1c38a62

Browse files
Ma KeLinus Walleij
authored andcommitted
pinctrl: single: fix potential NULL dereference in pcs_get_function()
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: 571aec4 ("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>
1 parent 752f387 commit 1c38a62

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/pinctrl/pinctrl-single.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ static int pcs_get_function(struct pinctrl_dev *pctldev, unsigned pin,
345345
return -ENOTSUPP;
346346
fselector = setting->func;
347347
function = pinmux_generic_get_function(pctldev, fselector);
348+
if (!function)
349+
return -EINVAL;
348350
*func = function->data;
349351
if (!(*func)) {
350352
dev_err(pcs->dev, "%s could not find function%i\n",

0 commit comments

Comments
 (0)