mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
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: ef10531681 ("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
This commit is contained in:
committed by
Maarten Lankhorst
parent
cce30b8311
commit
0a095b64fa
@@ -34,7 +34,6 @@ int _intel_color_pipeline_plane_init(struct drm_plane *plane, struct drm_prop_en
|
||||
return ret;
|
||||
|
||||
list->type = colorop->base.base.id;
|
||||
list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", colorop->base.base.id);
|
||||
|
||||
/* TODO: handle failures and clean up */
|
||||
prev_op = &colorop->base;
|
||||
@@ -74,6 +73,8 @@ int _intel_color_pipeline_plane_init(struct drm_plane *plane, struct drm_prop_en
|
||||
|
||||
drm_colorop_set_next_property(prev_op, &colorop->base);
|
||||
|
||||
list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", list->type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -81,9 +82,10 @@ int intel_color_pipeline_plane_init(struct drm_plane *plane, enum pipe pipe)
|
||||
{
|
||||
struct drm_device *dev = plane->dev;
|
||||
struct intel_display *display = to_intel_display(dev);
|
||||
struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES];
|
||||
struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES] = {};
|
||||
int len = 0;
|
||||
int ret;
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
/* Currently expose pipeline only for HDR planes */
|
||||
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)
|
||||
/* Add pipeline consisting of transfer functions */
|
||||
ret = _intel_color_pipeline_plane_init(plane, &pipelines[len], pipe);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto out;
|
||||
len++;
|
||||
|
||||
return drm_plane_create_color_pipeline_property(plane, pipelines, len);
|
||||
ret = drm_plane_create_color_pipeline_property(plane, pipelines, len);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
kfree(pipelines[i].name);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user