drm/amd/display: Avoid overflow from uint32_t to uint8_t
authorAlex Hung <alex.hung@amd.com>
Fri, 31 May 2024 17:51:26 +0000 (11:51 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 14 Jun 2024 20:18:26 +0000 (16:18 -0400)
[WHAT & HOW]
dmub_rb_cmd's ramping_boundary has size of uint8_t and it is assigned
0xFFFF. Fix it by changing it to uint8_t with value of 0xFF.

This fixes 2 INTEGER_OVERFLOW issues reported by Coverity.

Reviewed-by: Rodrigo Siqueira <rodrigo.siqueira@amd.com>
Acked-by: Zaeem Mohamed <zaeem.mohamed@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dce/dmub_abm_lcd.c
drivers/gpu/drm/amd/display/dc/hwss/dcn21/dcn21_hwseq.c

index f4987e96fbf937b9c8128dd47af7f9022909fc3e..0d7e7f3b81a1f82fe0e279cc0bb4df43c983f960 100644 (file)
@@ -258,7 +258,7 @@ bool dmub_abm_set_pipe(struct abm *abm,
 {
        union dmub_rb_cmd cmd;
        struct dc_context *dc = abm->ctx;
-       uint32_t ramping_boundary = 0xFFFF;
+       uint8_t ramping_boundary = 0xFF;
 
        memset(&cmd, 0, sizeof(cmd));
        cmd.abm_set_pipe.header.type = DMUB_CMD__ABM;
index 804be977ea47b505ad9af4e21aaa86f0315ec65f..3de65a9f0e6f2bda6fe146b7dcbc691e53301e48 100644 (file)
@@ -142,7 +142,7 @@ static bool dmub_abm_set_pipe(struct abm *abm, uint32_t otg_inst,
 {
        union dmub_rb_cmd cmd;
        struct dc_context *dc = abm->ctx;
-       uint32_t ramping_boundary = 0xFFFF;
+       uint8_t ramping_boundary = 0xFF;
 
        memset(&cmd, 0, sizeof(cmd));
        cmd.abm_set_pipe.header.type = DMUB_CMD__ABM;