mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
pinctrl: core: handle radix_tree_insert() errors in pinctrl_register_one_pin()
commit ecfe9a015d upstream.
pinctrl_register_one_pin() 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-3-s.shtylyov@omp.ru
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Cc: "Hemdan, Hagar Gamal Halim" <hagarhem@amazon.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
90cbd4c081
commit
026caf92c6
@@ -205,6 +205,7 @@ static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev,
|
|||||||
const struct pinctrl_pin_desc *pin)
|
const struct pinctrl_pin_desc *pin)
|
||||||
{
|
{
|
||||||
struct pin_desc *pindesc;
|
struct pin_desc *pindesc;
|
||||||
|
int error;
|
||||||
|
|
||||||
pindesc = pin_desc_get(pctldev, pin->number);
|
pindesc = pin_desc_get(pctldev, pin->number);
|
||||||
if (pindesc) {
|
if (pindesc) {
|
||||||
@@ -226,18 +227,25 @@ static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev,
|
|||||||
} else {
|
} else {
|
||||||
pindesc->name = kasprintf(GFP_KERNEL, "PIN%u", pin->number);
|
pindesc->name = kasprintf(GFP_KERNEL, "PIN%u", pin->number);
|
||||||
if (!pindesc->name) {
|
if (!pindesc->name) {
|
||||||
kfree(pindesc);
|
error = -ENOMEM;
|
||||||
return -ENOMEM;
|
goto failed;
|
||||||
}
|
}
|
||||||
pindesc->dynamic_name = true;
|
pindesc->dynamic_name = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pindesc->drv_data = pin->drv_data;
|
pindesc->drv_data = pin->drv_data;
|
||||||
|
|
||||||
radix_tree_insert(&pctldev->pin_desc_tree, pin->number, pindesc);
|
error = radix_tree_insert(&pctldev->pin_desc_tree, pin->number, pindesc);
|
||||||
|
if (error)
|
||||||
|
goto failed;
|
||||||
|
|
||||||
pr_debug("registered pin %d (%s) on %s\n",
|
pr_debug("registered pin %d (%s) on %s\n",
|
||||||
pin->number, pindesc->name, pctldev->desc->name);
|
pin->number, pindesc->name, pctldev->desc->name);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
failed:
|
||||||
|
kfree(pindesc);
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pinctrl_register_pins(struct pinctrl_dev *pctldev,
|
static int pinctrl_register_pins(struct pinctrl_dev *pctldev,
|
||||||
|
|||||||
Reference in New Issue
Block a user