Skip to content

Commit cce30b8

Browse files
ckborahMaarten Lankhorst
authored andcommitted
drm/vkms: Fix color pipeline enum name leak
vkms_initialize_colorops() allocates enum names for color pipelines, which are copied by drm_property_create_enum(). The temporary strings were not freed, resulting in a memory leak. Allocate enum names only after successful pipeline construction and free them on all exit paths Fixes: c1e578b ("drm/vkms: Add enumerated 1D curve colorop") 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> Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com> Signed-off-by: Maarten Lankhorst <dev@lankhorst.se> Link: https://patch.msgid.link/20260113102303.724205-4-chaitanya.kumar.borah@intel.com
1 parent 7d8257f commit cce30b8

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

drivers/gpu/drm/vkms/vkms_colorop.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
3737
goto cleanup;
3838

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

4241
i++;
4342

@@ -88,6 +87,8 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
8887

8988
drm_colorop_set_next_property(ops[i - 1], ops[i]);
9089

90+
list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[0]->base.id);
91+
9192
return 0;
9293

9394
cleanup:
@@ -103,18 +104,18 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
103104

104105
int vkms_initialize_colorops(struct drm_plane *plane)
105106
{
106-
struct drm_prop_enum_list pipeline;
107-
int ret;
107+
struct drm_prop_enum_list pipeline = {};
108+
int ret = 0;
108109

109110
/* Add color pipeline */
110111
ret = vkms_initialize_color_pipeline(plane, &pipeline);
111112
if (ret)
112-
return ret;
113+
goto out;
113114

114115
/* Create COLOR_PIPELINE property and attach */
115116
ret = drm_plane_create_color_pipeline_property(plane, &pipeline, 1);
116-
if (ret)
117-
return ret;
118117

119-
return 0;
118+
kfree(pipeline.name);
119+
out:
120+
return ret;
120121
}

0 commit comments

Comments
 (0)