summaryrefslogtreecommitdiff
path: root/drivers/regulator
diff options
context:
space:
mode:
authorYang Yingliang <yangyingliang@huawei.com>2022-11-15 12:15:08 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-01-18 11:26:13 +0300
commit4dfcf5087db9a34a300d6b99009232d4537c3e6a (patch)
tree782f6e60a930d9247f1f3e132e34e47f986e0da5 /drivers/regulator
parent5b510a82740d2a42a75b5661b402bcaf8ae22cd5 (diff)
downloadlinux-4dfcf5087db9a34a300d6b99009232d4537c3e6a.tar.xz
regulator: core: fix unbalanced of node refcount in regulator_dev_lookup()
[ Upstream commit f2b41b748c19962b82709d9f23c6b2b0ce9d2f91 ] I got the the following report: OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /i2c/pmic@62/regulators/exten In of_get_regulator(), the node is returned from of_parse_phandle() with refcount incremented, after using it, of_node_put() need be called. Fixes: 69511a452e6d ("regulator: map consumer regulator based on device tree") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Link: https://lore.kernel.org/r/20221115091508.900752-1-yangyingliang@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/core.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ce5162ef9216..d6cd8e6e69cf 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1478,6 +1478,7 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
node = of_get_regulator(dev, supply);
if (node) {
r = of_find_regulator_by_node(node);
+ of_node_put(node);
if (r)
return r;