未验证 提交 f2b41b74 编写于 作者: Y Yang Yingliang 提交者: Mark Brown

regulator: core: fix unbalanced of node refcount in regulator_dev_lookup()

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: 69511a45 ("regulator: map consumer regulator based on device tree")
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221115091508.900752-1-yangyingliang@huawei.comSigned-off-by: NMark Brown <broonie@kernel.org>
上级 91016037
...@@ -1943,6 +1943,7 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev, ...@@ -1943,6 +1943,7 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
node = of_get_regulator(dev, supply); node = of_get_regulator(dev, supply);
if (node) { if (node) {
r = of_find_regulator_by_node(node); r = of_find_regulator_by_node(node);
of_node_put(node);
if (r) if (r)
return r; return r;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册