drm/amd/display: Add hpd_source index out-of-bounds check for dcn3x link encoder...
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Wed, 9 Oct 2024 14:23:59 +0000 (19:53 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 15 Oct 2024 15:21:22 +0000 (11:21 -0400)
This patch adds a boundary check for the hpd_source index during the
link encoder creation process for dcn3x 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>
12 files changed:
drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c
drivers/gpu/drm/amd/display/dc/resource/dcn301/dcn301_resource.c
drivers/gpu/drm/amd/display/dc/resource/dcn302/dcn302_resource.c
drivers/gpu/drm/amd/display/dc/resource/dcn303/dcn303_resource.c
drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c
drivers/gpu/drm/amd/display/dc/resource/dcn314/dcn314_resource.c
drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c
drivers/gpu/drm/amd/display/dc/resource/dcn316/dcn316_resource.c
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c
drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c
drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
drivers/gpu/drm/amd/display/dc/resource/dcn351/dcn351_resource.c

index 5040a4c..baa4e26 100644 (file)
@@ -927,7 +927,7 @@ static struct link_encoder *dcn30_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;
 
        dcn30_link_encoder_construct(enc20,
index 7d04739..d8a7c2c 100644 (file)
@@ -883,7 +883,7 @@ static struct link_encoder *dcn301_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;
 
        dcn301_link_encoder_construct(enc20,
index 5791b5c..40c20b0 100644 (file)
@@ -893,7 +893,7 @@ static struct link_encoder *dcn302_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;
 
        dcn30_link_encoder_construct(enc20, enc_init_data, &link_enc_feature,
index 63f0f88..daf1b65 100644 (file)
@@ -839,7 +839,7 @@ static struct link_encoder *dcn303_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;
 
        dcn30_link_encoder_construct(enc20, enc_init_data, &link_enc_feature,
index ac8cb20..36bb261 100644 (file)
@@ -1093,7 +1093,7 @@ static struct link_encoder *dcn31_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;
 
        dcn31_link_encoder_construct(enc20,
index 169924d..58a5fbc 100644 (file)
@@ -1149,7 +1149,7 @@ static struct link_encoder *dcn31_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;
 
        dcn31_link_encoder_construct(enc20,
index f6b840f..3acad70 100644 (file)
@@ -1091,7 +1091,7 @@ static struct link_encoder *dcn31_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;
 
        dcn31_link_encoder_construct(enc20,
index 5fd52c5..ce56f5d 100644 (file)
@@ -1085,7 +1085,7 @@ static struct link_encoder *dcn31_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;
 
        dcn31_link_encoder_construct(enc20,
index a124ad9..a1890df 100644 (file)
@@ -1039,7 +1039,7 @@ static struct link_encoder *dcn32_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
index 827a94f..35acc13 100644 (file)
@@ -1035,7 +1035,7 @@ static struct link_encoder *dcn321_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
index 893a9d9..795f2c7 100644 (file)
@@ -1074,7 +1074,7 @@ static struct link_encoder *dcn35_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
index 70abd32..0b8dc2e 100644 (file)
@@ -1054,7 +1054,7 @@ static struct link_encoder *dcn35_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