Commit b56e23bf authored by Sergey Shtylyov's avatar Sergey Shtylyov Committed by Linus Walleij

pinctrl: core: handle radix_tree_insert() errors in pinctrl_generic_add_group()

pinctrl_generic_add_group() doesn't check the 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-2-s.shtylyov@omp.ruSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 87b549ef
...@@ -633,7 +633,7 @@ int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name, ...@@ -633,7 +633,7 @@ int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name,
int *pins, int num_pins, void *data) int *pins, int num_pins, void *data)
{ {
struct group_desc *group; struct group_desc *group;
int selector; int selector, error;
if (!name) if (!name)
return -EINVAL; return -EINVAL;
...@@ -653,7 +653,9 @@ int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name, ...@@ -653,7 +653,9 @@ int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name,
group->num_pins = num_pins; group->num_pins = num_pins;
group->data = data; group->data = data;
radix_tree_insert(&pctldev->pin_group_tree, selector, group); error = radix_tree_insert(&pctldev->pin_group_tree, selector, group);
if (error)
return error;
pctldev->num_groups++; pctldev->num_groups++;
......
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