Skip to content

Commit 7d8257f

Browse files
ckborahMaarten Lankhorst
authored andcommitted
drm/amd/display: Fix color pipeline enum name leak
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: 9ba2591 ("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
1 parent 7261305 commit 7d8257f

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
7979
goto cleanup;
8080

8181
list->type = ops[i]->base.id;
82-
list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]->base.id);
8382

8483
i++;
8584

@@ -197,6 +196,9 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
197196
goto cleanup;
198197

199198
drm_colorop_set_next_property(ops[i-1], ops[i]);
199+
200+
list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[0]->base.id);
201+
200202
return 0;
201203

202204
cleanup:

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,12 +1790,13 @@ dm_atomic_plane_get_property(struct drm_plane *plane,
17901790
static int
17911791
dm_plane_init_colorops(struct drm_plane *plane)
17921792
{
1793-
struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES];
1793+
struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES] = {};
17941794
struct drm_device *dev = plane->dev;
17951795
struct amdgpu_device *adev = drm_to_adev(dev);
17961796
struct dc *dc = adev->dm.dc;
17971797
int len = 0;
1798-
int ret;
1798+
int ret = 0;
1799+
int i;
17991800

18001801
if (plane->type == DRM_PLANE_TYPE_CURSOR)
18011802
return 0;
@@ -1806,15 +1807,19 @@ dm_plane_init_colorops(struct drm_plane *plane)
18061807
if (ret) {
18071808
drm_err(plane->dev, "Failed to create color pipeline for plane %d: %d\n",
18081809
plane->base.id, ret);
1809-
return ret;
1810+
goto out;
18101811
}
18111812
len++;
18121813

18131814
/* Create COLOR_PIPELINE property and attach */
18141815
drm_plane_create_color_pipeline_property(plane, pipelines, len);
18151816
}
18161817

1817-
return 0;
1818+
out:
1819+
for (i = 0; i < len; i++)
1820+
kfree(pipelines[i].name);
1821+
1822+
return ret;
18181823
}
18191824
#endif
18201825

0 commit comments

Comments
 (0)