Commit 7dfd28ac authored by Colin Ian King's avatar Colin Ian King Committed by Kelsey Skunberg

drm/radeon: fix array out-of-bounds read and write issues

BugLink: https://bugs.launchpad.net/bugs/1892822

[ Upstream commit 7ee78aff ]

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: cc8dbbb4 ("drm/radeon: add dpm support for CI dGPUs (v2)")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarIan May <ian.may@canonical.com>
Signed-off-by: default avatarKelsey Skunberg <kelsey.skunberg@canonical.com>
parent b5d0c22c
...@@ -4345,7 +4345,7 @@ static int ci_set_mc_special_registers(struct radeon_device *rdev, ...@@ -4345,7 +4345,7 @@ static int ci_set_mc_special_registers(struct radeon_device *rdev,
table->mc_reg_table_entry[k].mc_data[j] |= 0x100; table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
} }
j++; j++;
if (j > SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE) if (j >= SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE)
return -EINVAL; return -EINVAL;
if (!pi->mem_gddr5) { if (!pi->mem_gddr5) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment