Commit 7d8257fe authored by Chaitanya Kumar Borah's avatar Chaitanya Kumar Borah Committed by Maarten Lankhorst
Browse files

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: 9ba25915 ("drm/amd/display: Add support for sRGB EOTF in DEGAM block")
Signed-off-by: default avatarChaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Reviewed-by: default avatarUma Shankar <uma.shankar@intel.com>
Reviewed-by: default avatarAlex Hung <alex.hung@amd.com>
Signed-off-by: default avatarMaarten 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
parent 7261305d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -79,7 +79,6 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
		goto cleanup;

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

	i++;

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

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

	list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[0]->base.id);

	return 0;

cleanup:
+9 −4
Original line number Diff line number Diff line
@@ -1790,12 +1790,13 @@ dm_atomic_plane_get_property(struct drm_plane *plane,
static int
dm_plane_init_colorops(struct drm_plane *plane)
{
	struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES];
	struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES] = {};
	struct drm_device *dev = plane->dev;
	struct amdgpu_device *adev = drm_to_adev(dev);
	struct dc *dc = adev->dm.dc;
	int len = 0;
	int ret;
	int ret = 0;
	int i;

	if (plane->type == DRM_PLANE_TYPE_CURSOR)
		return 0;
@@ -1806,7 +1807,7 @@ dm_plane_init_colorops(struct drm_plane *plane)
		if (ret) {
			drm_err(plane->dev, "Failed to create color pipeline for plane %d: %d\n",
				plane->base.id, ret);
			return ret;
			goto out;
		}
		len++;

@@ -1814,7 +1815,11 @@ dm_plane_init_colorops(struct drm_plane *plane)
		drm_plane_create_color_pipeline_property(plane, pipelines, len);
	}

	return 0;
out:
	for (i = 0; i < len; i++)
		kfree(pipelines[i].name);

	return ret;
}
#endif