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

drm/amd/display: add protection in link encoder matching logic

[Why]
Link encoders are created based on its engine ID. The position of a link
encoder in an array could be null since it didn't be allocated. Current
matching logic didn't consider this situation and could get null
encoder.

[How]
To add null encoder check to make the matching logic can go to next to
get a valid one.

Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Reviewed-by: Aric Cyr <Aric.Cyr@amd.com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Martin Tsai <martin.tsai@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Martin Tsai and committed by
Alex Deucher
d715c9a2 09ece5ac

+36 -92
+1 -1
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 8366 8366 break; 8367 8367 case DRM_MODE_CONNECTOR_DisplayPort: 8368 8368 aconnector->base.polled = DRM_CONNECTOR_POLL_HPD; 8369 - link->link_enc = dp_get_link_enc(link); 8369 + link->link_enc = link_enc_cfg_get_link_enc(link); 8370 8370 ASSERT(link->link_enc); 8371 8371 if (link->link_enc) 8372 8372 aconnector->base.ycbcr_420_allowed =
+1 -10
drivers/gpu/drm/amd/display/dc/core/dc_link.c
··· 4621 4621 */ 4622 4622 struct link_encoder *link_enc = NULL; 4623 4623 4624 - /* Links supporting dynamically assigned link encoder will be assigned next 4625 - * available encoder if one not already assigned. 4626 - */ 4627 - if (link->is_dig_mapping_flexible && 4628 - link->dc->res_pool->funcs->link_encs_assign) { 4629 - link_enc = link_enc_cfg_get_link_enc_used_by_link(link->ctx->dc, link); 4630 - if (link_enc == NULL) 4631 - link_enc = link_enc_cfg_get_next_avail_link_enc(link->ctx->dc); 4632 - } else 4633 - link_enc = link->link_enc; 4624 + link_enc = link_enc_cfg_get_link_enc(link); 4634 4625 ASSERT(link_enc); 4635 4626 4636 4627 return (dc_is_dp_signal(link->connector_signal) && link_enc &&