Skip to content

Commit a0cedbc

Browse files
henryZelinusw
authored andcommitted
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: 91d5c50 ("pinctrl: devicetree: fix null pointer dereferencing in pinctrl_dt_to_map") Suggested-by: Dan Carpenter <[email protected]> Signed-off-by: Zeng Heng <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Message-ID: <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent c5d3b64 commit a0cedbc

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/pinctrl/devicetree.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,16 @@ int pinctrl_dt_to_map(struct pinctrl *p, struct pinctrl_dev *pctldev)
220220
for (state = 0; ; state++) {
221221
/* Retrieve the pinctrl-* property */
222222
propname = kasprintf(GFP_KERNEL, "pinctrl-%d", state);
223-
if (!propname)
224-
return -ENOMEM;
223+
if (!propname) {
224+
ret = -ENOMEM;
225+
goto err;
226+
}
225227
prop = of_find_property(np, propname, &size);
226228
kfree(propname);
227229
if (!prop) {
228230
if (state == 0) {
229-
of_node_put(np);
230-
return -ENODEV;
231+
ret = -ENODEV;
232+
goto err;
231233
}
232234
break;
233235
}

0 commit comments

Comments
 (0)