summaryrefslogtreecommitdiff
path: root/drivers/pinctrl/core.c
diff options
context:
space:
mode:
authorSergey Shtylyov <s.shtylyov@omp.ru>2023-07-19 23:22:51 +0300
committerLinus Walleij <linus.walleij@linaro.org>2023-07-28 23:08:58 +0300
commitb56e23bf0c606b68df2919317f7065dabe3c4e86 (patch)
tree09f09b41057b8350a894d13267fae8f2657c0047 /drivers/pinctrl/core.c
parent87b549efcb0f7934b0916d2a00607a878b6f1e0f (diff)
downloadlinux-b56e23bf0c606b68df2919317f7065dabe3c4e86.tar.xz
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: Sergey Shtylyov <s.shtylyov@omp.ru> Link: https://lore.kernel.org/r/20230719202253.13469-2-s.shtylyov@omp.ru Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/core.c')
-rw-r--r--drivers/pinctrl/core.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 401886c81344..3c3fc4ae0f2f 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -633,7 +633,7 @@ int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name,
int *pins, int num_pins, void *data)
{
struct group_desc *group;
- int selector;
+ int selector, error;
if (!name)
return -EINVAL;
@@ -653,7 +653,9 @@ int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name,
group->num_pins = num_pins;
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++;