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

drm/amd/display: Deallocate DML memory if allocation fails

[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>

authored by

Chris Park and committed by
Alex Deucher
892abca6 35ff747c

+8 -2
+8 -2
drivers/gpu/drm/amd/display/dc/core/dc_state.c
··· 211 211 #ifdef CONFIG_DRM_AMD_DC_FP 212 212 if (dc->debug.using_dml2) { 213 213 dml2_opt->use_clock_dc_limits = false; 214 - dml2_create(dc, dml2_opt, &state->bw_ctx.dml2); 214 + if (!dml2_create(dc, dml2_opt, &state->bw_ctx.dml2)) { 215 + dc_state_release(state); 216 + return NULL; 217 + } 215 218 216 219 dml2_opt->use_clock_dc_limits = true; 217 - dml2_create(dc, dml2_opt, &state->bw_ctx.dml2_dc_power_source); 220 + if (!dml2_create(dc, dml2_opt, &state->bw_ctx.dml2_dc_power_source)) { 221 + dc_state_release(state); 222 + return NULL; 223 + } 218 224 } 219 225 #endif 220 226