Commit a0cedbcc authored by Zeng Heng's avatar Zeng Heng Committed by Linus Walleij

pinctrl: devicetree: fix refcount leak in pinctrl_dt_to_map()

If we fail to allocate propname buffer, we need to drop the reference
count we just took. Because the pinctrl_dt_free_maps() includes the
droping operation, here we call it directly.

Fixes: 91d5c506 ("pinctrl: devicetree: fix null pointer dereferencing in pinctrl_dt_to_map")
Suggested-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: default avatarZeng Heng <zengheng4@huawei.com>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Message-ID: <20240415105328.3651441-1-zengheng4@huawei.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent c5d3b64c
...@@ -220,14 +220,16 @@ int pinctrl_dt_to_map(struct pinctrl *p, struct pinctrl_dev *pctldev) ...@@ -220,14 +220,16 @@ int pinctrl_dt_to_map(struct pinctrl *p, struct pinctrl_dev *pctldev)
for (state = 0; ; state++) { for (state = 0; ; state++) {
/* Retrieve the pinctrl-* property */ /* Retrieve the pinctrl-* property */
propname = kasprintf(GFP_KERNEL, "pinctrl-%d", state); propname = kasprintf(GFP_KERNEL, "pinctrl-%d", state);
if (!propname) if (!propname) {
return -ENOMEM; ret = -ENOMEM;
goto err;
}
prop = of_find_property(np, propname, &size); prop = of_find_property(np, propname, &size);
kfree(propname); kfree(propname);
if (!prop) { if (!prop) {
if (state == 0) { if (state == 0) {
of_node_put(np); ret = -ENODEV;
return -ENODEV; goto err;
} }
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment