]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/display: Release state memory if amdgpu_dm_create_color_properties fail
authorHersen Wu <hersenxs.wu@amd.com>
Thu, 25 Apr 2024 00:32:53 +0000 (20:32 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 2 May 2024 20:18:17 +0000 (16:18 -0400)
[Why]
Coverity reports RESOURCE_LEAK warning. State memory
is not released if dm_create_color_properties fail.

[How]
Call kfree(state) before return.

Reviewed-by: Alex Hung <alex.hung@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Acked-by: Tom Chung <chiahsuan.chung@amd.com>
Signed-off-by: Hersen Wu <hersenxs.wu@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index 35bf77fe53af051079cf70153a17287a6e7110de..bcb6030c013a90b2281e4a638aca4de669b8a419 100644 (file)
@@ -4229,8 +4229,11 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev)
        }
 
 #ifdef AMD_PRIVATE_COLOR
-       if (amdgpu_dm_create_color_properties(adev))
+       if (amdgpu_dm_create_color_properties(adev)) {
+               dc_state_release(state->context);
+               kfree(state);
                return -ENOMEM;
+       }
 #endif
 
        r = amdgpu_dm_audio_init(adev);