Skip to content

Commit b56e23b

Browse files
Sergey Shtylyovlinusw
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 87b549e commit b56e23b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/pinctrl/core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name,
633633
int *pins, int num_pins, void *data)
634634
{
635635
struct group_desc *group;
636-
int selector;
636+
int selector, error;
637637

638638
if (!name)
639639
return -EINVAL;
@@ -653,7 +653,9 @@ int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name,
653653
group->num_pins = num_pins;
654654
group->data = data;
655655

656-
radix_tree_insert(&pctldev->pin_group_tree, selector, group);
656+
error = radix_tree_insert(&pctldev->pin_group_tree, selector, group);
657+
if (error)
658+
return error;
657659

658660
pctldev->num_groups++;
659661

0 commit comments

Comments
 (0)