summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2021-07-03 12:44:12 +0300
committerAlex Deucher <alexander.deucher@amd.com>2021-07-08 15:17:02 -0400
commit3006c9245542609d3a11b856b6d17cfce747ca88 (patch)
tree4688a9063d943a7c3eadcae40de20ccb75676afa /drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
parent7b101c95486cffbc65be4b41eda0d49f8cbb0173 (diff)
downloadlinux-stable-3006c9245542609d3a11b856b6d17cfce747ca88.tar.gz
linux-stable-3006c9245542609d3a11b856b6d17cfce747ca88.tar.bz2
linux-stable-3006c9245542609d3a11b856b6d17cfce747ca88.zip
drm/amdgpu: fix a signedness bug in __verify_ras_table_checksum()
If amdgpu_eeprom_read() returns a negative error code then the error handling checks: if (res < buf_size) { The problem is that "buf_size" is a u32 so negative values are type promoted to a high positive values and the condition is false. Fix this by changing the type of "buf_size" to int. Fixes: 63d4c081a556a1 ("drm/amdgpu: Optimize EEPROM RAS table I/O") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Luben Tuikov <luben.tuikov@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
index fc70620369e4..f07a456506ef 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
@@ -978,9 +978,8 @@ const struct file_operations amdgpu_ras_debugfs_eeprom_table_ops = {
static int __verify_ras_table_checksum(struct amdgpu_ras_eeprom_control *control)
{
struct amdgpu_device *adev = to_amdgpu_device(control);
- int res;
+ int buf_size, res;
u8 csum, *buf, *pp;
- u32 buf_size;
buf_size = RAS_TABLE_HEADER_SIZE +
control->ras_num_recs * RAS_TABLE_RECORD_SIZE;