]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: Add hpd_source index check for DCE60/80/100/110/112/120 link encoders
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Thu, 17 Oct 2024 01:58:45 +0000 (07:28 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 22 Oct 2024 21:50:37 +0000 (17:50 -0400)
This patch adds a boundary check for the hpd_source index during the
link encoder creation process for all DCExxx 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/dce60/dce60_resource.c
drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.c
drivers/gpu/drm/amd/display/dc/resource/dce110/dce110_resource.c
drivers/gpu/drm/amd/display/dc/resource/dce112/dce112_resource.c
drivers/gpu/drm/amd/display/dc/resource/dce120/dce120_resource.c
drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c

index 8db9f75144662eb5598689fa9c759d0c3dba7021..889f314cac65cb0d748b8a0204d8cc86761684e8 100644 (file)
@@ -717,7 +717,7 @@ static struct link_encoder *dce60_link_encoder_create(
                kzalloc(sizeof(struct dce110_link_encoder), GFP_KERNEL);
        int link_regs_id;
 
-       if (!enc110)
+       if (!enc110 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
                return NULL;
 
        link_regs_id =
index 53a5f4cb648cbd62a366de8dd704e24de1363df5..e698543ec93747062a03df49d0a88d3388c4bc5d 100644 (file)
@@ -623,7 +623,7 @@ static struct link_encoder *dce100_link_encoder_create(
                kzalloc(sizeof(struct dce110_link_encoder), GFP_KERNEL);
        int link_regs_id;
 
-       if (!enc110)
+       if (!enc110 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
                return NULL;
 
        link_regs_id =
index 91da5cf85b69fa37fbe02c4d71a78cede041617a..035c6cfdaee570296bd512b6a45accce68dfd9a9 100644 (file)
@@ -668,7 +668,7 @@ static struct link_encoder *dce110_link_encoder_create(
                kzalloc(sizeof(struct dce110_link_encoder), GFP_KERNEL);
        int link_regs_id;
 
-       if (!enc110)
+       if (!enc110 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
                return NULL;
 
        link_regs_id =
index 162856c523e40c3c9c8849f5bbec2e49944b4593..480a50967385165a72b6a72037727dd1fd014c06 100644 (file)
@@ -629,7 +629,7 @@ static struct link_encoder *dce112_link_encoder_create(
                kzalloc(sizeof(struct dce110_link_encoder), GFP_KERNEL);
        int link_regs_id;
 
-       if (!enc110)
+       if (!enc110 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
                return NULL;
 
        link_regs_id =
index 621825a51f46e1e6a5c788fa24a89b2134c71654..c63c5962343332fac2b6e3e8c5a3d84b3beea487 100644 (file)
@@ -706,7 +706,7 @@ static struct link_encoder *dce120_link_encoder_create(
                kzalloc(sizeof(struct dce110_link_encoder), GFP_KERNEL);
        int link_regs_id;
 
-       if (!enc110)
+       if (!enc110 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
                return NULL;
 
        link_regs_id =
index a73d3c6ef425856b7cd8748b7cb01aeeea4ef4e1..3d5113f010bb4fa4788d8f787affc77ffc36bc21 100644 (file)
@@ -723,7 +723,7 @@ static struct link_encoder *dce80_link_encoder_create(
                kzalloc(sizeof(struct dce110_link_encoder), GFP_KERNEL);
        int link_regs_id;
 
-       if (!enc110)
+       if (!enc110 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
                return NULL;
 
        link_regs_id =