]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/display: Fix color pipeline enum name leak
authorChaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Tue, 13 Jan 2026 10:22:54 +0000 (15:52 +0530)
committerMaarten Lankhorst <dev@lankhorst.se>
Thu, 22 Jan 2026 09:26:55 +0000 (10:26 +0100)
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>
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
drivers/gpu/drm/i915/display/intel_color_pipeline.c

index 684641c8323b56bf3670a1943f24c5395c10102a..04af552b36488593f4e7092118a70ceb87d2766d 100644 (file)
@@ -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;
 }