Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	intel-xe@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Cc: harry.wentland@amd.com, jani.nikula@linux.intel.com,
	louis.chauvet@bootlin.com, mwen@igalia.com, contact@emersion.fr,
	alex.hung@amd.com, daniels@collabora.com, uma.shankar@intel.com,
	suraj.kandpal@intel.com, nfraprado@collabora.com,
	ville.syrjala@linux.intel.com, matthew.d.roper@intel.com
Subject: [PATCH v3 04/13] drm/i915/display: Fix color pipeline enum name leak
Date: Tue, 13 Jan 2026 15:52:54 +0530	[thread overview]
Message-ID: <20260113102303.724205-5-chaitanya.kumar.borah@intel.com> (raw)
In-Reply-To: <20260113102303.724205-1-chaitanya.kumar.borah@intel.com>

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: ef105316819d ("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>
---
 .../drm/i915/display/intel_color_pipeline.c    | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_color_pipeline.c b/drivers/gpu/drm/i915/display/intel_color_pipeline.c
index 684641c8323b..04af552b3648 100644
--- a/drivers/gpu/drm/i915/display/intel_color_pipeline.c
+++ b/drivers/gpu/drm/i915/display/intel_color_pipeline.c
@@ -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;
 }
-- 
2.25.1


  parent reply	other threads:[~2026-01-13 10:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-13 10:22 [PATCH v3 00/13] drm: Color pipeline teardown and follow-up fixes/improvements Chaitanya Kumar Borah
2026-01-13 10:22 ` [PATCH v3 01/13] drm/i915/color: Place 3D LUT after CSC in plane color pipeline Chaitanya Kumar Borah
2026-01-13 10:22 ` [PATCH v3 02/13] drm/amd/display: Fix color pipeline enum name leak Chaitanya Kumar Borah
2026-01-13 10:22 ` [PATCH v3 03/13] drm/vkms: " Chaitanya Kumar Borah
2026-01-13 10:22 ` Chaitanya Kumar Borah [this message]
2026-01-13 10:22 ` [PATCH v3 05/13] drm/colorop: Add destroy helper for colorop objects Chaitanya Kumar Borah
2026-01-13 10:22 ` [PATCH v3 06/13] drm: Allow driver-managed destruction of " Chaitanya Kumar Borah
2026-01-14  5:37   ` Kandpal, Suraj
2026-01-14  7:51     ` Borah, Chaitanya Kumar
2026-01-13 10:22 ` [PATCH v3 07/13] drm/amd/display: Hook up colorop destroy helper for plane pipelines Chaitanya Kumar Borah
2026-01-13 10:22 ` [PATCH v3 08/13] drm/vkms: " Chaitanya Kumar Borah
2026-01-13 10:22 ` [PATCH v3 09/13] drm/i915/display: Hook up intel_colorop_destroy Chaitanya Kumar Borah
2026-01-13 10:23 ` [PATCH v3 10/13] drm: Clean up colorop objects during mode_config cleanup Chaitanya Kumar Borah
2026-01-13 10:23 ` [PATCH v3 11/13] drm/vkms: Remove drm_colorop_pipeline_destroy() from vkms_destroy() Chaitanya Kumar Borah
2026-01-13 10:23 ` [PATCH v3 12/13] drm/colorop: Use destroy callback for color pipeline teardown Chaitanya Kumar Borah
2026-01-13 10:23 ` [PATCH v3 13/13] drm/i915/color: Add failure handling in plane color pipeline init Chaitanya Kumar Borah
2026-01-13 12:40 ` ✓ i915.CI.BAT: success for drm: Color pipeline teardown and follow-up fixes/improvements (rev3) Patchwork
2026-01-13 16:49 ` ✓ i915.CI.Full: " Patchwork
2026-01-21 13:51 ` [PATCH v3 00/13] drm: Color pipeline teardown and follow-up fixes/improvements Jani Nikula
2026-01-22  9:57   ` Maarten Lankhorst
2026-01-27  6:00     ` Borah, Chaitanya Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260113102303.724205-5-chaitanya.kumar.borah@intel.com \
    --to=chaitanya.kumar.borah@intel.com \
    --cc=alex.hung@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=contact@emersion.fr \
    --cc=daniels@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=harry.wentland@amd.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=louis.chauvet@bootlin.com \
    --cc=matthew.d.roper@intel.com \
    --cc=mwen@igalia.com \
    --cc=nfraprado@collabora.com \
    --cc=suraj.kandpal@intel.com \
    --cc=uma.shankar@intel.com \
    --cc=ville.syrjala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox