drm/radeon: fix array out-of-bounds read and write issues
authorColin Ian King <colin.king@canonical.com>
Wed, 24 Jun 2020 12:07:10 +0000 (13:07 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 1 Jul 2020 05:59:26 +0000 (01:59 -0400)
There is an off-by-one bounds check on the index into arrays
table->mc_reg_address and table->mc_reg_table_entry[k].mc_data[j] that
can lead to reads and writes outside of arrays. Fix the bound checking
off-by-one error.

Addresses-Coverity: ("Out-of-bounds read/write")
Fixes: cc8dbbb4f62a ("drm/radeon: add dpm support for CI dGPUs (v2)")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/ci_dpm.c

index 134aa2b..86ac032 100644 (file)
@@ -4351,7 +4351,7 @@ static int ci_set_mc_special_registers(struct radeon_device *rdev,
                                        table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
                        }
                        j++;
-                       if (j > SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)
+                       if (j >= SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)
                                return -EINVAL;
 
                        if (!pi->mem_gddr5) {