Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/vkms: Fix color pipeline enum name leak

vkms_initialize_colorops() 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: c1e578bd08da ("drm/vkms: Add enumerated 1D curve colorop")
Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
Link: https://patch.msgid.link/20260113102303.724205-4-chaitanya.kumar.borah@intel.com

authored by

Chaitanya Kumar Borah and committed by
Maarten Lankhorst
cce30b83 7d8257fe

+8 -7
+8 -7
drivers/gpu/drm/vkms/vkms_colorop.c
··· 37 37 goto cleanup; 38 38 39 39 list->type = ops[i]->base.id; 40 - list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]->base.id); 41 40 42 41 i++; 43 42 ··· 87 88 88 89 drm_colorop_set_next_property(ops[i - 1], ops[i]); 89 90 91 + list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[0]->base.id); 92 + 90 93 return 0; 91 94 92 95 cleanup: ··· 104 103 105 104 int vkms_initialize_colorops(struct drm_plane *plane) 106 105 { 107 - struct drm_prop_enum_list pipeline; 108 - int ret; 106 + struct drm_prop_enum_list pipeline = {}; 107 + int ret = 0; 109 108 110 109 /* Add color pipeline */ 111 110 ret = vkms_initialize_color_pipeline(plane, &pipeline); 112 111 if (ret) 113 - return ret; 112 + goto out; 114 113 115 114 /* Create COLOR_PIPELINE property and attach */ 116 115 ret = drm_plane_create_color_pipeline_property(plane, &pipeline, 1); 117 - if (ret) 118 - return ret; 119 116 120 - return 0; 117 + kfree(pipeline.name); 118 + out: 119 + return ret; 121 120 }