Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <s.shtylyov@omp.ru>
Link: https://lore.kernel.org/r/20230719202253.13469-4-s.shtylyov@omp.ru
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Sergey Shtylyov and committed by
Linus Walleij
6ec89cd4 ecfe9a01

+4 -2
+4 -2
drivers/pinctrl/pinmux.c
··· 872 872 void *data) 873 873 { 874 874 struct function_desc *function; 875 - int selector; 875 + int selector, error; 876 876 877 877 if (!name) 878 878 return -EINVAL; ··· 892 892 function->num_group_names = num_groups; 893 893 function->data = data; 894 894 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; 896 898 897 899 pctldev->num_functions++; 898 900