mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-24 13:13:57 +08:00
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>
This commit is contained in:
parent
a38fd87484
commit
ba434267d0
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user