Commit 6ec89cd4 authored by Sergey Shtylyov's avatar Sergey Shtylyov Committed by Linus Walleij

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: default avatarSergey Shtylyov <s.shtylyov@omp.ru>
Link: https://lore.kernel.org/r/20230719202253.13469-4-s.shtylyov@omp.ruSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent ecfe9a01
...@@ -872,7 +872,7 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev, ...@@ -872,7 +872,7 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
void *data) void *data)
{ {
struct function_desc *function; struct function_desc *function;
int selector; int selector, error;
if (!name) if (!name)
return -EINVAL; return -EINVAL;
...@@ -892,7 +892,9 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev, ...@@ -892,7 +892,9 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
function->num_group_names = num_groups; function->num_group_names = num_groups;
function->data = data; function->data = data;
radix_tree_insert(&pctldev->pin_function_tree, selector, function); error = radix_tree_insert(&pctldev->pin_function_tree, selector, function);
if (error)
return error;
pctldev->num_functions++; pctldev->num_functions++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment