Skip to content

Commit 0a095b6

Browse files
ckborahMaarten Lankhorst
authored andcommitted
drm/i915/display: Fix color pipeline enum name leak
intel_color_pipeline_plane_init() 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: ef10531 ("drm/i915/color: Create a transfer function color pipeline") Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com> Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com> Reviewed-by: Uma Shankar <uma.shankar@intel.com> Signed-off-by: Maarten Lankhorst <dev@lankhorst.se> Acked-by: Jani Nikula <jani.nikula@intel.com> Link: https://patch.msgid.link/20260113102303.724205-5-chaitanya.kumar.borah@intel.com
1 parent cce30b8 commit 0a095b6

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

drivers/gpu/drm/i915/display/intel_color_pipeline.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ int _intel_color_pipeline_plane_init(struct drm_plane *plane, struct drm_prop_en
3434
return ret;
3535

3636
list->type = colorop->base.base.id;
37-
list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", colorop->base.base.id);
3837

3938
/* TODO: handle failures and clean up */
4039
prev_op = &colorop->base;
@@ -74,16 +73,19 @@ int _intel_color_pipeline_plane_init(struct drm_plane *plane, struct drm_prop_en
7473

7574
drm_colorop_set_next_property(prev_op, &colorop->base);
7675

76+
list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", list->type);
77+
7778
return 0;
7879
}
7980

8081
int intel_color_pipeline_plane_init(struct drm_plane *plane, enum pipe pipe)
8182
{
8283
struct drm_device *dev = plane->dev;
8384
struct intel_display *display = to_intel_display(dev);
84-
struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES];
85+
struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES] = {};
8586
int len = 0;
86-
int ret;
87+
int ret = 0;
88+
int i;
8789

8890
/* Currently expose pipeline only for HDR planes */
8991
if (!icl_is_hdr_plane(display, to_intel_plane(plane)->id))
@@ -92,8 +94,14 @@ int intel_color_pipeline_plane_init(struct drm_plane *plane, enum pipe pipe)
9294
/* Add pipeline consisting of transfer functions */
9395
ret = _intel_color_pipeline_plane_init(plane, &pipelines[len], pipe);
9496
if (ret)
95-
return ret;
97+
goto out;
9698
len++;
9799

98-
return drm_plane_create_color_pipeline_property(plane, pipelines, len);
100+
ret = drm_plane_create_color_pipeline_property(plane, pipelines, len);
101+
102+
for (i = 0; i < len; i++)
103+
kfree(pipelines[i].name);
104+
105+
out:
106+
return ret;
99107
}

0 commit comments

Comments
 (0)