From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB4516FA0 for ; Mon, 16 Jan 2023 17:03:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BE3CC433D2; Mon, 16 Jan 2023 17:03:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673888624; bh=vzoHGS+S1Gu/M+dbz91evZO4kuebFM+zJyNIfuuudE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2khVHB7SuMQUmnNN6fgpzz2lqFsI/lHpMnHek7C8qHQpJHOVUburjZ3aTobrg9cMY vL0X3GbMI/AnbLlZhvaKV3IMqFrJLhema91/MmwPjADp6tJ6hc6LKycb/CSaFEGDx7 VA/Skxm1hHJtjbLmx+Sl24QEsbDcP6n3y+VuLbYU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yang Yingliang , Mark Brown , Sasha Levin Subject: [PATCH 4.14 075/338] regulator: core: fix unbalanced of node refcount in regulator_dev_lookup() Date: Mon, 16 Jan 2023 16:49:08 +0100 Message-Id: <20230116154824.149293215@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154820.689115727@linuxfoundation.org> References: <20230116154820.689115727@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Yang Yingliang [ 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 --- drivers/regulator/core.c | 1 + 1 file changed, 1 insertion(+) 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; -- 2.35.1