]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/msm/adreno: Fix a reference leak in a6xx_gpu_init()
authorFelix Gu <ustc.gu@gmail.com>
Fri, 23 Jan 2026 16:37:38 +0000 (00:37 +0800)
committerRob Clark <robin.clark@oss.qualcomm.com>
Wed, 13 May 2026 21:07:27 +0000 (14:07 -0700)
In a6xx_gpu_init(), node is obtained via of_parse_phandle().
While there was a manual of_node_put() at the end of the
common path, several early error returns would bypass this call,
resulting in a reference leak.
Fix this by using the __free(device_node) cleanup handler to
release the reference when the variable goes out of scope.

Fixes: 5a903a44a984 ("drm/msm/a6xx: Introduce GMU wrapper support")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Patchwork: https://patchwork.freedesktop.org/patch/700661/
Message-ID: <20260124-a6xx_gpu-v1-1-fa0c8b2dcfb1@gmail.com>
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
drivers/gpu/drm/msm/adreno/a6xx_gpu.c

index 615509c8917e81b1bac9dfba518b8df9bd98f58e..1e455391fbac0254e7f33405fc9fd1447631249a 100644 (file)
@@ -2621,7 +2621,6 @@ static struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)
        struct platform_device *pdev = priv->gpu_pdev;
        struct adreno_platform_config *config = pdev->dev.platform_data;
        const struct adreno_info *info = config->info;
-       struct device_node *node;
        struct a6xx_gpu *a6xx_gpu;
        struct adreno_gpu *adreno_gpu;
        struct msm_gpu *gpu;
@@ -2643,7 +2642,8 @@ static struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)
        adreno_gpu->registers = NULL;
 
        /* Check if there is a GMU phandle and set it up */
-       node = of_parse_phandle(pdev->dev.of_node, "qcom,gmu", 0);
+       struct device_node *node __free(device_node) =
+               of_parse_phandle(pdev->dev.of_node, "qcom,gmu", 0);
        /* FIXME: How do we gracefully handle this? */
        BUG_ON(!node);
 
@@ -2690,7 +2690,6 @@ static struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)
                ret = a6xx_gmu_wrapper_init(a6xx_gpu, node);
        else
                ret = a6xx_gmu_init(a6xx_gpu, node);
-       of_node_put(node);
        if (ret) {
                a6xx_destroy(&(a6xx_gpu->base.base));
                return ERR_PTR(ret);