Commit 0a095b64 authored by Chaitanya Kumar Borah's avatar Chaitanya Kumar Borah Committed by Maarten Lankhorst
Browse files

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: ef105316 ("drm/i915/color: Create a transfer function color pipeline")
Signed-off-by: default avatarChaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Reviewed-by: default avatarSuraj Kandpal <suraj.kandpal@intel.com>
Reviewed-by: default avatarUma Shankar <uma.shankar@intel.com>
Signed-off-by: default avatarMaarten Lankhorst <dev@lankhorst.se>
Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
Link: https://patch.msgid.link/20260113102303.724205-5-chaitanya.kumar.borah@intel.com
parent cce30b83
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -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;
}