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

Configure Feed

Select the types of activity you want to include in your feed.

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: 9ba25915efba ("drm/amd/display: Add support for sRGB EOTF in DEGAM block")
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>
Signed-off-by: Maarten 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

authored by

Chaitanya Kumar Borah and committed by
Maarten Lankhorst
7d8257fe 7261305d

+12 -5
+3 -1
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
··· 79 79 goto cleanup; 80 80 81 81 list->type = ops[i]->base.id; 82 - list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]->base.id); 83 82 84 83 i++; 85 84 ··· 196 197 goto cleanup; 197 198 198 199 drm_colorop_set_next_property(ops[i-1], ops[i]); 200 + 201 + list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[0]->base.id); 202 + 199 203 return 0; 200 204 201 205 cleanup:
+9 -4
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
··· 1790 1790 static int 1791 1791 dm_plane_init_colorops(struct drm_plane *plane) 1792 1792 { 1793 - struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES]; 1793 + struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES] = {}; 1794 1794 struct drm_device *dev = plane->dev; 1795 1795 struct amdgpu_device *adev = drm_to_adev(dev); 1796 1796 struct dc *dc = adev->dm.dc; 1797 1797 int len = 0; 1798 - int ret; 1798 + int ret = 0; 1799 + int i; 1799 1800 1800 1801 if (plane->type == DRM_PLANE_TYPE_CURSOR) 1801 1802 return 0; ··· 1807 1806 if (ret) { 1808 1807 drm_err(plane->dev, "Failed to create color pipeline for plane %d: %d\n", 1809 1808 plane->base.id, ret); 1810 - return ret; 1809 + goto out; 1811 1810 } 1812 1811 len++; 1813 1812 ··· 1815 1814 drm_plane_create_color_pipeline_property(plane, pipelines, len); 1816 1815 } 1817 1816 1818 - return 0; 1817 + out: 1818 + for (i = 0; i < len; i++) 1819 + kfree(pipelines[i].name); 1820 + 1821 + return ret; 1819 1822 } 1820 1823 #endif 1821 1824