diff options
author | Junlin Yang <yangjunlin@yulong.com> | 2021-02-16 11:02:31 +0300 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2021-03-10 16:41:12 +0300 |
commit | ba434267d07661f3e3712e4e5429ba599b32ab0e (patch) | |
tree | 45bc055dc1b40574c1ed7da89e2a4dfe775660f4 /drivers/pinctrl/pinctrl-equilibrium.c | |
parent | a38fd8748464831584a19438cbb3082b5a2dab15 (diff) | |
download | linux-ba434267d07661f3e3712e4e5429ba599b32ab0e.tar.xz |
pinctrl: equilibrium: add missing of_node_put
Fix OF node leaks by calling of_node_put in
for_each_child_of_node when the cycle returns.
Generated by: scripts/coccinelle/iterators/for_each_child.cocci
Signed-off-by: Junlin Yang <yangjunlin@yulong.com>
Link: https://lore.kernel.org/r/20210216080231.1303-1-angkery@163.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-equilibrium.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-equilibrium.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/pinctrl/pinctrl-equilibrium.c b/drivers/pinctrl/pinctrl-equilibrium.c index 067271b7d35a..a194d8089b6f 100644 --- a/drivers/pinctrl/pinctrl-equilibrium.c +++ b/drivers/pinctrl/pinctrl-equilibrium.c @@ -628,7 +628,8 @@ static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs, break; default: - return -EINVAL; + of_node_put(np); + return -EINVAL; } i++; } @@ -707,34 +708,42 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata) group.num_pins = of_property_count_u32_elems(np, "pins"); if (group.num_pins < 0) { dev_err(dev, "No pins in the group: %s\n", prop->name); + of_node_put(np); return -EINVAL; } group.name = prop->value; group.pins = devm_kcalloc(dev, group.num_pins, sizeof(*(group.pins)), GFP_KERNEL); - if (!group.pins) + if (!group.pins) { + of_node_put(np); return -ENOMEM; + } pinmux = devm_kcalloc(dev, group.num_pins, sizeof(*pinmux), GFP_KERNEL); - if (!pinmux) + if (!pinmux) { + of_node_put(np); return -ENOMEM; + } for (j = 0; j < group.num_pins; j++) { if (of_property_read_u32_index(np, "pins", j, &pin_id)) { dev_err(dev, "Group %s: Read intel pins id failed\n", group.name); + of_node_put(np); return -EINVAL; } if (pin_id >= drvdata->pctl_desc.npins) { dev_err(dev, "Group %s: Invalid pin ID, idx: %d, pin %u\n", group.name, j, pin_id); + of_node_put(np); return -EINVAL; } group.pins[j] = pin_id; if (of_property_read_u32_index(np, "pinmux", j, &pinmux_id)) { dev_err(dev, "Group %s: Read intel pinmux id failed\n", group.name); + of_node_put(np); return -EINVAL; } pinmux[j] = pinmux_id; @@ -745,6 +754,7 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata) pinmux); if (err < 0) { dev_err(dev, "Failed to register group %s\n", group.name); + of_node_put(np); return err; } memset(&group, 0, sizeof(group)); |