summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJoe Hattori <joe@pf.is.s.u-tokyo.ac.jp>2024-12-15 12:01:59 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-01-17 13:36:25 +0100
commit66e533f0b250a2f848602ba935c0bfc40a55a592 (patch)
treefe5fe7f6429bfcf26a4da708af678c1955aefd29 /drivers
parentb1e6351c16b4703a2ba08c66cb928ae2108757e2 (diff)
downloadlinux-66e533f0b250a2f848602ba935c0bfc40a55a592.tar.gz
linux-66e533f0b250a2f848602ba935c0bfc40a55a592.tar.bz2
linux-66e533f0b250a2f848602ba935c0bfc40a55a592.zip
pmdomain: imx: gpcv2: fix an OF node reference leak in imx_gpcv2_probe()
[ 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: 03aa12629fc4 ("soc: imx: Add GPCv2 power gating driver") Signed-off-by: Joe 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: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pmdomain/imx/gpcv2.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/pmdomain/imx/gpcv2.c b/drivers/pmdomain/imx/gpcv2.c
index ec789bf92274..13fce2b134f6 100644
--- a/drivers/pmdomain/imx/gpcv2.c
+++ b/drivers/pmdomain/imx/gpcv2.c
@@ -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;