Skip to content

Commit 1c38a62

Browse files
Ma Kelinusw
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: [email protected] Fixes: 571aec4 ("pinctrl: single: Use generic pinmux helpers for managing functions") Signed-off-by: Ma Ke <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 752f387 commit 1c38a62

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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)