From: Yang Yingliang Date: Tue, 15 Nov 2022 09:15:08 +0000 (+0800) Subject: regulator: core: fix unbalanced of node refcount in regulator_dev_lookup() X-Git-Tag: v4.9.337~195 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e88505ac0a6ae97746bcdbd4b042ee9f20455ae;p=thirdparty%2Fkernel%2Fstable.git 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 Link: https://lore.kernel.org/r/20221115091508.900752-1-yangyingliang@huawei.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 23323add5b0b1..e1f934fec5624 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1471,6 +1471,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; *ret = -EPROBE_DEFER;