Skip to content

Commit 469c068

Browse files
joehattoristorulf
authored andcommitted
pmdomain: imx: gpcv2: fix an OF node reference leak in imx_gpcv2_probe()
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: 03aa126 ("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>
1 parent fac04ef commit 469c068

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/pmdomain/imx/gpcv2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,12 +1458,12 @@ static int imx_gpcv2_probe(struct platform_device *pdev)
14581458
.max_register = SZ_4K,
14591459
};
14601460
struct device *dev = &pdev->dev;
1461-
struct device_node *pgc_np;
1461+
struct device_node *pgc_np __free(device_node) =
1462+
of_get_child_by_name(dev->of_node, "pgc");
14621463
struct regmap *regmap;
14631464
void __iomem *base;
14641465
int ret;
14651466

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

0 commit comments

Comments
 (0)