]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: Ensure HPD source index is valid for dcn20/dcn201 link encoders
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Tue, 15 Oct 2024 15:12:39 +0000 (20:42 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 22 Oct 2024 21:50:12 +0000 (17:50 -0400)
This patch adds a boundary check for the hpd_source index during the
link encoder creation process for dcn20/dcn201 IP's. 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 <chiahsuan.chung@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Roman Li <roman.li@amd.com>
Cc: Alex Hung <alex.hung@amd.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Hamza Mahfooz <hamza.mahfooz@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: Roman Li <roman.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/resource/dcn20/dcn20_resource.c
drivers/gpu/drm/amd/display/dc/resource/dcn201/dcn201_resource.c

index eea2b3b307cd5f9a7aacb97528dd9410b80d2803..288189913e1ec8abb9a92bd7964b6f4f6d26d778 100644 (file)
@@ -920,7 +920,7 @@ struct link_encoder *dcn20_link_encoder_create(
                kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
        int link_regs_id;
 
-       if (!enc20)
+       if (!enc20 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
                return NULL;
 
        link_regs_id =
index fc54483b91047a1677d8a326ed6a7b9d1ab0ef97..15180ad71513d99675a9b71783508d51d1ea4e11 100644 (file)
@@ -797,7 +797,7 @@ static struct link_encoder *dcn201_link_encoder_create(
                kzalloc(sizeof(struct dcn20_link_encoder), GFP_ATOMIC);
        struct dcn10_link_encoder *enc10;
 
-       if (!enc20)
+       if (!enc20 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
                return NULL;
 
        enc10 = &enc20->enc10;