Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47d253c4 authored by Zeng Heng's avatar Zeng Heng Committed by Greg Kroah-Hartman
Browse files

pinctrl: devicetree: fix refcount leak in pinctrl_dt_to_map()



[ Upstream commit a0cedbcc8852d6c77b00634b81e41f17f29d9404 ]

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: 91d5c5060ee2 ("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>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 8ade2092
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -223,14 +223,16 @@ int pinctrl_dt_to_map(struct pinctrl *p, struct pinctrl_dev *pctldev)
	for (state = 0; ; state++) {
		/* Retrieve the pinctrl-* property */
		propname = kasprintf(GFP_KERNEL, "pinctrl-%d", state);
		if (!propname)
			return -ENOMEM;
		if (!propname) {
			ret = -ENOMEM;
			goto err;
		}
		prop = of_find_property(np, propname, &size);
		kfree(propname);
		if (!prop) {
			if (state == 0) {
				of_node_put(np);
				return -ENODEV;
				ret = -ENODEV;
				goto err;
			}
			break;
		}