]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: Fix color pipeline enum name leak
authorChaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Tue, 13 Jan 2026 10:22:52 +0000 (15:52 +0530)
committerMaarten Lankhorst <dev@lankhorst.se>
Thu, 22 Jan 2026 09:24:55 +0000 (10:24 +0100)
dm_plane_init_colorops() allocates enum names for color pipelines.
These are eventually passed to drm_property_create_enum() which create
its own copies of the string. Free the strings after initialization
is done.

Also, allocate color pipeline enum names only after successfully creating
color pipeline.

Fixes: 9ba25915efba ("drm/amd/display: Add support for sRGB EOTF in DEGAM block")
Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
Acked-by: Alex Deucher <alexander.deucher@amd.com> #irc
Link: https://patch.msgid.link/20260113102303.724205-3-chaitanya.kumar.borah@intel.com
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c

index d585618b8064eadbbf1d0b3a1bb25d9e35d87ca8..a2de3bba83464622c2170988fd37818155d7e8fd 100644 (file)
@@ -79,7 +79,6 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
                goto cleanup;
 
        list->type = ops[i]->base.id;
-       list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]->base.id);
 
        i++;
 
@@ -197,6 +196,9 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
                goto cleanup;
 
        drm_colorop_set_next_property(ops[i-1], ops[i]);
+
+       list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[0]->base.id);
+
        return 0;
 
 cleanup:
index 2e3ee78999d99d4b109620e41c1b6c52784fad0f..7c4496fb4b9d48bdcc2bf320066e46660b7ee2f0 100644 (file)
@@ -1790,12 +1790,13 @@ dm_atomic_plane_get_property(struct drm_plane *plane,
 static int
 dm_plane_init_colorops(struct drm_plane *plane)
 {
-       struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES];
+       struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES] = {};
        struct drm_device *dev = plane->dev;
        struct amdgpu_device *adev = drm_to_adev(dev);
        struct dc *dc = adev->dm.dc;
        int len = 0;
-       int ret;
+       int ret = 0;
+       int i;
 
        if (plane->type == DRM_PLANE_TYPE_CURSOR)
                return 0;
@@ -1806,7 +1807,7 @@ dm_plane_init_colorops(struct drm_plane *plane)
                if (ret) {
                        drm_err(plane->dev, "Failed to create color pipeline for plane %d: %d\n",
                                plane->base.id, ret);
-                       return ret;
+                       goto out;
                }
                len++;
 
@@ -1814,7 +1815,11 @@ dm_plane_init_colorops(struct drm_plane *plane)
                drm_plane_create_color_pipeline_property(plane, pipelines, len);
        }
 
-       return 0;
+out:
+       for (i = 0; i < len; i++)
+               kfree(pipelines[i].name);
+
+       return ret;
 }
 #endif