Commit 73cb5f6e authored by Wentao Liang's avatar Wentao Liang Committed by Ulf Hansson
Browse files

pmdomain: imx: Fix reference count leak in imx_gpc_probe()



of_get_child_by_name() returns a node pointer with refcount incremented.
Use the __free() attribute to manage the pgc_node reference, ensuring
automatic of_node_put() cleanup when pgc_node goes out of scope.

This eliminates the need for explicit error handling paths and avoids
reference count leaks.

Fixes: 721cabf6 ("soc: imx: move PGC handling to a new GPC driver")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarWentao Liang <vulab@iscas.ac.cn>
Reviewed-by: default avatarFrank Li <Frank.Li@nxp.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 305f2547
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -402,13 +402,12 @@ static int imx_gpc_old_dt_init(struct device *dev, struct regmap *regmap,
static int imx_gpc_probe(struct platform_device *pdev)
{
	const struct imx_gpc_dt_data *of_id_data = device_get_match_data(&pdev->dev);
	struct device_node *pgc_node;
	struct device_node *pgc_node __free(device_node)
		= of_get_child_by_name(pdev->dev.of_node, "pgc");
	struct regmap *regmap;
	void __iomem *base;
	int ret;

	pgc_node = of_get_child_by_name(pdev->dev.of_node, "pgc");

	/* bail out if DT too old and doesn't provide the necessary info */
	if (!of_property_present(pdev->dev.of_node, "#power-domain-cells") &&
	    !pgc_node)