Skip to content

Commit 688c688

Browse files
Bartosz Golaszewskigregkh
authored andcommitted
pinctrl: check the return value of pinmux_ops::get_function_name()
commit 4002ee9 upstream. While the API contract in docs doesn't specify it explicitly, the generic implementation of the get_function_name() callback from struct pinmux_ops - pinmux_generic_get_function_name() - can fail and return NULL. This is already checked in pinmux_check_ops() so add a similar check in pinmux_func_name_to_selector() instead of passing the returned pointer right down to strcmp() where the NULL can get dereferenced. This is normal operation when adding new pinfunctions. Cc: [email protected] Tested-by: Neil Armstrong <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9338093 commit 688c688

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/pinctrl/pinmux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static int pinmux_func_name_to_selector(struct pinctrl_dev *pctldev,
337337
while (selector < nfuncs) {
338338
const char *fname = ops->get_function_name(pctldev, selector);
339339

340-
if (!strcmp(function, fname))
340+
if (fname && !strcmp(function, fname))
341341
return selector;
342342

343343
selector++;

0 commit comments

Comments
 (0)