]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amd/display: Deallocate DML memory if allocation fails
authorChris Park <chris.park@amd.com>
Fri, 28 Jun 2024 19:09:06 +0000 (15:09 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 23 Jul 2024 21:07:11 +0000 (17:07 -0400)
[Why]
When DC state create DML memory allocation fails, memory is not
deallocated subsequently, resulting in uninitialized structure
that is not NULL.

[How]
Deallocate memory if DML memory allocation fails.

Reviewed-by: Joshua Aberback <joshua.aberback@amd.com>
Signed-off-by: Jerry Zuo <jerry.zuo@amd.com>
Signed-off-by: Chris Park <chris.park@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_state.c

index e990346e51f67ea74f8fb1d764d9b7071fb48923..665157f8d4cbe23089cdb1ce3eb689302c56f325 100644 (file)
@@ -211,10 +211,16 @@ struct dc_state *dc_state_create(struct dc *dc, struct dc_state_create_params *p
 #ifdef CONFIG_DRM_AMD_DC_FP
        if (dc->debug.using_dml2) {
                dml2_opt->use_clock_dc_limits = false;
-               dml2_create(dc, dml2_opt, &state->bw_ctx.dml2);
+               if (!dml2_create(dc, dml2_opt, &state->bw_ctx.dml2)) {
+                       dc_state_release(state);
+                       return NULL;
+               }
 
                dml2_opt->use_clock_dc_limits = true;
-               dml2_create(dc, dml2_opt, &state->bw_ctx.dml2_dc_power_source);
+               if (!dml2_create(dc, dml2_opt, &state->bw_ctx.dml2_dc_power_source)) {
+                       dc_state_release(state);
+                       return NULL;
+               }
        }
 #endif