Commit 4d2106bf authored by Miaoqian Lin's avatar Miaoqian Lin Committed by Zicheng Qu
Browse files

regulator: pfuze100: Fix refcount leak in pfuze_parse_regulators_dt

stable inclusion
from stable-v4.19.247
commit 984cfef0675ed7398814e14af2c5323911723e1c
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBP43Y
CVE: CVE-2022-49481

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=984cfef0675ed7398814e14af2c5323911723e1c



--------------------------------

[ Upstream commit afaa7b93 ]

of_node_get() returns a node with refcount incremented.
Calling of_node_put() to drop the reference when not needed anymore.

Fixes: 3784b6d6 ("regulator: pfuze100: add pfuze100 regulator driver")
Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
Link: https://lore.kernel.org/r/20220511113506.45185-1-linmq006@gmail.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarZicheng Qu <quzicheng@huawei.com>
parent 4d1e2474
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -495,6 +495,7 @@ static int pfuze_parse_regulators_dt(struct pfuze_chip *chip)
	parent = of_get_child_by_name(np, "regulators");
	if (!parent) {
		dev_err(dev, "regulators node not found\n");
		of_node_put(np);
		return -EINVAL;
	}

@@ -524,6 +525,7 @@ static int pfuze_parse_regulators_dt(struct pfuze_chip *chip)
	}

	of_node_put(parent);
	of_node_put(np);
	if (ret < 0) {
		dev_err(dev, "Error parsing regulator init data: %d\n",
			ret);