Commit 00dd0099 authored by Joe Hattori's avatar Joe Hattori Committed by Wen Zhiwei
Browse files

pmdomain: imx: gpcv2: fix an OF node reference leak in imx_gpcv2_probe()

stable inclusion
from stable-v6.6.72
commit 66e533f0b250a2f848602ba935c0bfc40a55a592
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBQN9L

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=66e533f0b250a2f848602ba935c0bfc40a55a592



--------------------------------

[ Upstream commit 469c0682e03d67d8dc970ecaa70c2d753057c7c0 ]

imx_gpcv2_probe() leaks an OF node reference obtained by
of_get_child_by_name(). Fix it by declaring the device node with the
__free(device_node) cleanup construct.

This bug was found by an experimental static analysis tool that I am
developing.

Fixes: 03aa1262 ("soc: imx: Add GPCv2 power gating driver")
Signed-off-by: default avatarJoe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Cc: stable@vger.kernel.org
Message-ID: <20241215030159.1526624-1-joe@pf.is.s.u-tokyo.ac.jp>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent 24a72a03
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1449,12 +1449,12 @@ static int imx_gpcv2_probe(struct platform_device *pdev)
		.max_register   = SZ_4K,
	};
	struct device *dev = &pdev->dev;
	struct device_node *pgc_np;
	struct device_node *pgc_np __free(device_node) =
		of_get_child_by_name(dev->of_node, "pgc");
	struct regmap *regmap;
	void __iomem *base;
	int ret;

	pgc_np = of_get_child_by_name(dev->of_node, "pgc");
	if (!pgc_np) {
		dev_err(dev, "No power domains specified in DT\n");
		return -EINVAL;