Skip to content

Commit 73cb5f6

Browse files
ISCAS-Vulabstorulf
authored andcommitted
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: 721cabf ("soc: imx: move PGC handling to a new GPC driver") Cc: stable@vger.kernel.org Signed-off-by: Wentao Liang <vulab@iscas.ac.cn> Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 305f254 commit 73cb5f6

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

  • drivers/pmdomain/imx

drivers/pmdomain/imx/gpc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,12 @@ static int imx_gpc_old_dt_init(struct device *dev, struct regmap *regmap,
402402
static int imx_gpc_probe(struct platform_device *pdev)
403403
{
404404
const struct imx_gpc_dt_data *of_id_data = device_get_match_data(&pdev->dev);
405-
struct device_node *pgc_node;
405+
struct device_node *pgc_node __free(device_node)
406+
= of_get_child_by_name(pdev->dev.of_node, "pgc");
406407
struct regmap *regmap;
407408
void __iomem *base;
408409
int ret;
409410

410-
pgc_node = of_get_child_by_name(pdev->dev.of_node, "pgc");
411-
412411
/* bail out if DT too old and doesn't provide the necessary info */
413412
if (!of_property_present(pdev->dev.of_node, "#power-domain-cells") &&
414413
!pgc_node)

0 commit comments

Comments
 (0)