aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
diff options
context:
space:
mode:
authorDan Carpenter <[email protected]>2021-07-03 09:44:57 +0000
committerAlex Deucher <[email protected]>2021-07-08 19:18:14 +0000
commit1d864f1088bbcf7f6ffa83053dcc8684a1a436cb (patch)
tree6a266e4074f287ca75910e314f4810d6bd7716cf /drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
parentdrm/amdgpu: fix a signedness bug in __verify_ras_table_checksum() (diff)
downloadkernel-1d864f1088bbcf7f6ffa83053dcc8684a1a436cb.tar.gz
kernel-1d864f1088bbcf7f6ffa83053dcc8684a1a436cb.zip
drm/amdgpu: Fix signedness bug in __amdgpu_eeprom_xfer()
The i2c_transfer() function returns negatives or else the number of messages transferred. This code does not work because ARRAY_SIZE() is type size_t and so that means negative values of "r" are type promoted to high positive values which are greater than the ARRAY_SIZE(). Fix this by changing the < to != which works regardless of type promotion. Fixes: 746b584762e452 ("drm/amdgpu: Fixes to the AMDGPU EEPROM driver") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Luben Tuikov <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
index 4c3c65a5acae..4d9eb0137f8c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
@@ -147,7 +147,7 @@ static int __amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,
/* This constitutes a START-STOP transaction.
*/
r = i2c_transfer(i2c_adap, msgs, ARRAY_SIZE(msgs));
- if (r < ARRAY_SIZE(msgs))
+ if (r != ARRAY_SIZE(msgs))
break;
if (!read) {