Skip to content

Commit 6ec89cd

Browse files
Sergey Shtylyovlinusw
authored andcommitted
pinctrl: pinmux: handle radix_tree_insert() errors in pinmux_generic_add_function()
pinctrl_generic_add_function() doesn't check result of radix_tree_insert() despite they both may return a negative error code. Linus Walleij said he has copied the radix tree code from kernel/irq/ where the functions calling radix_tree_insert() are *void* themselves; I think it makes more sense to propagate the errors from radix_tree_insert() upstream if we can do that... Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool. Signed-off-by: Sergey Shtylyov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent ecfe9a0 commit 6ec89cd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/pinctrl/pinmux.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
872872
void *data)
873873
{
874874
struct function_desc *function;
875-
int selector;
875+
int selector, error;
876876

877877
if (!name)
878878
return -EINVAL;
@@ -892,7 +892,9 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
892892
function->num_group_names = num_groups;
893893
function->data = data;
894894

895-
radix_tree_insert(&pctldev->pin_function_tree, selector, function);
895+
error = radix_tree_insert(&pctldev->pin_function_tree, selector, function);
896+
if (error)
897+
return error;
896898

897899
pctldev->num_functions++;
898900

0 commit comments

Comments
 (0)