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 AADE81863 for ; Wed, 28 Dec 2022 15:41:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F713C433D2; Wed, 28 Dec 2022 15:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672242119; bh=ubWeeaA8fsgBEhF+PVzwUK5e0SKPTu5LKDQzOw58iIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vacUoRehfOnYvPTITUhBKp7AhZqy0sbGO/t/wMtlPFtnM1yNNNiyzBpIVA1HFaRAC bbJuD54CPFf1bLP9LwI3QtwHuPrht5ZOQpcuejw5BQyH5lXHFIUkgoYiqMb8ysqM56 zNO1kq2YCjNPBIFF+5mgSjHJJvww5cq/HJDD3i3g= 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 6.1 0331/1146] regulator: core: fix unbalanced of node refcount in regulator_dev_lookup() Date: Wed, 28 Dec 2022 15:31:10 +0100 Message-Id: <20221228144339.149581889@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228144330.180012208@linuxfoundation.org> References: <20221228144330.180012208@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 e8c00a884f1f..bc4bba899aea 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1943,6 +1943,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