summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWentao Liang <vulab@iscas.ac.cn>2025-12-11 07:02:52 +0300
committerUlf Hansson <ulf.hansson@linaro.org>2025-12-29 13:41:09 +0300
commit73cb5f6eafb0ac7aea8cdeb8ff12981aa741d8fb (patch)
tree78facf5b7cd1147fdd3975fc95a77fd45ac663ee
parent305f254727bd379bbed0385afa0162f5bde1f51c (diff)
downloadlinux-73cb5f6eafb0ac7aea8cdeb8ff12981aa741d8fb.tar.xz
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: 721cabf6c660 ("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>
-rw-r--r--drivers/pmdomain/imx/gpc.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/pmdomain/imx/gpc.c b/drivers/pmdomain/imx/gpc.c
index a34b260274f7..de695f1944ab 100644
--- a/drivers/pmdomain/imx/gpc.c
+++ b/drivers/pmdomain/imx/gpc.c
@@ -402,13 +402,12 @@ clk_err:
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)