From: Srinivasan Shanmugam Date: Thu, 17 Oct 2024 02:06:46 +0000 (+0530) Subject: drm/amd/display: Add hpd_source index check for dcn401 link encoder setup X-Git-Tag: microblaze-v6.16~490^2~20^2~41 X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=86b5be6ea20a9c8f4b23bf4377be48e5d7facfcb;p=linux-2.6-microblaze.git drm/amd/display: Add hpd_source index check for dcn401 link encoder setup This patch adds a boundary check for the hpd_source index during the link encoder creation process for all dcn401 ip. The check ensures that the index is within the valid range of the link_enc_hpd_regs array to prevent out-of-bounds access. Cc: Tom Chung Cc: Rodrigo Siqueira Cc: Roman Li Cc: Alex Hung Cc: Aurabindo Pillai Cc: Harry Wentland Cc: Hamza Mahfooz Signed-off-by: Srinivasan Shanmugam Reviewed-by: Roman Li Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c index 46feff9348d9..b425b34dc7f5 100644 --- a/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c +++ b/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c @@ -1032,7 +1032,7 @@ static struct link_encoder *dcn401_link_encoder_create( struct dcn20_link_encoder *enc20 = kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL); - if (!enc20) + if (!enc20 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs)) return NULL; #undef REG_STRUCT